Skip to content

Fix fluentd lifecycle hook: add Filter field and pre-push delete - #840

Merged
ricardobernardino2024 merged 1 commit into
release-17.0.0from
chunk/fix-fluentd-lifecycle-hook-filter
Sep 1, 2026
Merged

Fix fluentd lifecycle hook: add Filter field and pre-push delete#840
ricardobernardino2024 merged 1 commit into
release-17.0.0from
chunk/fix-fluentd-lifecycle-hook-filter

Conversation

@circleci-app

@circleci-app circleci-app Bot commented Sep 1, 2026

Copy link
Copy Markdown

Summary

Fixes the recurring BackoffLimitExceeded failure in deploy_to_doks_release (job 31035, step "Install Codacy").

Root cause analysis:

The 15-minute timing in the failed job is the main Codacy deployment rollout. After pods are ready, the post-upgrade hook (fluentd-lifecycle-policy-creator job) runs and fails immediately because the lifecycle configuration JSON is missing the Filter field now required by the MinIO version in use. With backoffLimit: 3 (set by PR #839), three quick failures trigger BackoffLimitExceeded.

A secondary issue: chart museum returns 409: already exists when a CI run tries to push codacy-17.0.0-RC-1.tgz again (seen in job 31005). This caused the first pipeline run to fail at helm_push_incubator, and the fix from PR #839 only reached chart museum when the chart was cleared between runs.

Changes:

  • codacy/templates/fluentd/lifecycle-police-job.yaml: Add "Filter":{} to the lifecycle rule JSON. The AWS S3 spec (and newer MinIO) requires a Filter element in every lifecycle rule. Without it, put-bucket-lifecycle-configuration returns MalformedXML and the hook pod exits non-zero on the first attempt.

  • .circleci/config.yml: Before helm push, call the ChartMuseum REST API to delete any existing version (DELETE /api/charts/codacy/<version>). Uses || true so it is a no-op when the version doesn't exist yet. This ensures each CI run can cleanly push the updated chart without 409 conflicts.

Test plan

  • Verify helm_push_incubator succeeds without 409 on a re-push of the same RC version
  • Verify deploy_to_doks_release completes without BackoffLimitExceeded on the next pipeline run
  • Confirm the fluentd lifecycle hook job pod exits 0 after the fix

https://app.circleci.com/agents/gh/codacy/chat/3b6f1bd6-1439-46f0-a4f9-9a1c30717a7d

… pre-push delete

Two fixes for the persistent deploy_to_doks_release failure (job 31035):

1. codacy/templates/fluentd/lifecycle-police-job.yaml: Add "Filter":{} to
   the lifecycle configuration JSON. Newer MinIO versions strictly follow the
   AWS S3 spec which requires a Filter element in each lifecycle rule, even
   when empty. Without it, put-bucket-lifecycle-configuration returns a
   MalformedXML error immediately, causing 3 fast pod failures and
   BackoffLimitExceeded (the ~15 min total time is main-deployment rollout;
   the hook itself fails in seconds).

2. .circleci/config.yml: Delete the existing chart version from chart museum
   before pushing. Chart museum rejects re-uploads of the same version with
   409, which failed the first pipeline run (job 31005). Adding a pre-push
   DELETE via the chart museum REST API (with || true to tolerate missing
   charts) ensures subsequent CI runs can always push the updated chart.

AI-Generated: true
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

@codacy-production codacy-production Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR addresses deployment failures by updating the fluentd lifecycle configuration for S3/MinIO compatibility and adding a pre-push cleanup step in the CI pipeline. Although the analysis shows the PR is up to standards according to Codacy, a critical risk was identified in the .circleci/config.yml. The DELETE request used to clear existing chart versions lacks validation for the version string; an empty value could result in the deletion of all chart versions. Additionally, while the template changes correctly implement the 'Filter' field, the manual JSON construction is fragile and should be hardened with default values.

Test suggestions

  • Verify the presence of 'Filter':{} in the lifecycle policy JSON within the fluentd-lifecycle-policy-creator template.
  • Verify that 'curl -X DELETE' is called with correct credentials and URL before 'helm push' in .circleci/config.yml.
  • Ensure the 'helm_push' job handles cases where the chart version does not exist on ChartMuseum without failing the pipeline step.

TIP Improve review quality by adding custom instructions
TIP How was this review? Give us feedback

Comment thread .circleci/config.yml
ENDPOINT="http://{{ .Values.global.minio.location }}:{{ .Values.global.minio.port }}"
BUCKET="{{ .Values.fluentdoperator.bucketName }}"
LIFECYCLE='{"Rules":[{"Expiration":{"Days": {{ .Values.fluentdoperator.expirationDays }} },"ID":"Delete old logs","Status":"Enabled"}]}'
LIFECYCLE='{"Rules":[{"Expiration":{"Days": {{ .Values.fluentdoperator.expirationDays }} },"Filter":{},"ID":"Delete old logs","Status":"Enabled"}]}'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ LOW RISK

Suggestion: The inclusion of '"Filter": {}' correctly implements S3 Lifecycle V2 requirements. Note that this manually constructed JSON string will be malformed if '.Values.fluentdoperator.expirationDays' is missing or non-numeric, which would cause the job to fail.

Try running the following prompt in your coding agent:

Update the Helm template to use a default value for expirationDays and ensure it is treated as a numeric value to prevent generating malformed JSON.

@ricardobernardino2024
ricardobernardino2024 merged commit 82b1310 into release-17.0.0 Sep 1, 2026
9 checks passed
@ricardobernardino2024
ricardobernardino2024 deleted the chunk/fix-fluentd-lifecycle-hook-filter branch September 1, 2026 08:11
ricardobernardino2024 pushed a commit that referenced this pull request Sep 2, 2026
PR #841 accidentally removed the `"Filter":{}` field that PR #840 had
added to the S3 lifecycle rule JSON. Newer MinIO versions strictly follow
the AWS S3 spec and require a Filter element in each lifecycle rule (even
when empty). Without it, put-bucket-lifecycle-configuration returns
MalformedXML immediately, causing the in-shell retry loop to exhaust its
5 attempts and exit with failure, which Kubernetes surfaces as
BackoffLimitExceeded on the post-upgrade hook.

AI-Generated: true

Co-authored-by: circleci-app[bot] <127350680+circleci-app[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant