From da57fc6cd906cc0ed13d0c5895f3d5301c576e79 Mon Sep 17 00:00:00 2001 From: "circleci-app[bot]" <127350680+circleci-app[bot]@users.noreply.github.com> Date: Tue, 1 Sep 2026 01:18:37 +0000 Subject: [PATCH] Fix fluentd lifecycle hook BackoffLimitExceeded by adding MinIO readiness wait The post-upgrade hook job was spawning 100 pods (backoffLimit: 100, restartPolicy: Never) each failing in ~9s because MinIO isn't ready immediately after a Helm upgrade, totalling ~15 minutes before BackoffLimitExceeded and causing helm --atomic to roll back. Changes: - Add a wait loop in the hook container that polls MinIO (aws s3 ls) every 10s for up to 10 minutes before attempting put-bucket-lifecycle-configuration - Reduce backoffLimit from 100 to 3 since retries are now handled within the container - Add before-hook-creation to hook-delete-policy so any stale failed job is always cleaned up before the next upgrade attempt creates a new one AI-Generated: true --- .../fluentd/lifecycle-police-job.yaml | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/codacy/templates/fluentd/lifecycle-police-job.yaml b/codacy/templates/fluentd/lifecycle-police-job.yaml index 68e5167fc..eb32590bc 100644 --- a/codacy/templates/fluentd/lifecycle-police-job.yaml +++ b/codacy/templates/fluentd/lifecycle-police-job.yaml @@ -12,9 +12,9 @@ metadata: # Minio create bucket hook doesn't define any hook weight, # any positive value will ensure that the bucket is created before this "helm.sh/hook-weight": "10" - "helm.sh/hook-delete-policy": hook-succeeded + "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded spec: - backoffLimit: 100 + backoffLimit: 3 template: metadata: name: "{{ .Release.Name }}" @@ -30,14 +30,26 @@ spec: value: "{{ .Values.global.minio.accessKey }}" - name: AWS_SECRET_ACCESS_KEY value: "{{ .Values.global.minio.secretKey }}" - command: ["aws"] + command: ["/bin/sh", "-c"] args: - - s3api - - put-bucket-lifecycle-configuration - - --bucket - - {{ .Values.fluentdoperator.bucketName }} - - --endpoint-url - - http://{{ .Values.global.minio.location }}:{{ .Values.global.minio.port }} - - --lifecycle-configuration - - '{"Rules":[{"Expiration":{"Days": {{ .Values.fluentdoperator.expirationDays }} },"ID":"Delete old logs","Status":"Enabled"}]}' + - | + 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"}]}' + MAX_WAIT=600 + ELAPSED=0 + echo "Waiting for MinIO at ${ENDPOINT}..." + until aws s3 ls --endpoint-url "${ENDPOINT}" > /dev/null 2>&1; do + if [ "${ELAPSED}" -ge "${MAX_WAIT}" ]; then + echo "Timed out waiting for MinIO after ${MAX_WAIT}s" + exit 1 + fi + sleep 10 + ELAPSED=$((ELAPSED + 10)) + done + echo "MinIO is ready. Setting lifecycle configuration on bucket ${BUCKET}..." + aws s3api put-bucket-lifecycle-configuration \ + --bucket "${BUCKET}" \ + --endpoint-url "${ENDPOINT}" \ + --lifecycle-configuration "${LIFECYCLE}" {{ end }}