Skip to content

Add retry logic for helm install hook failures in release deploy - #838

Merged
ricardobernardino2024 merged 1 commit into
release-17.0.0from
chunk/retry-helm-install-on-hook-failure
Sep 1, 2026
Merged

Add retry logic for helm install hook failures in release deploy#838
ricardobernardino2024 merged 1 commit into
release-17.0.0from
chunk/retry-helm-install-on-hook-failure

Conversation

@circleci-app

@circleci-app circleci-app Bot commented Aug 31, 2026

Copy link
Copy Markdown

Summary

  • Job 30935 (deploy_to_doks_release) failed at "Install Codacy" with: UPGRADE FAILED: post-upgrade hooks failed: job failed: BackoffLimitExceeded
  • The stale job cleanup added by Clean up stale hook jobs before helm upgrade to fix BackoffLimitExceeded #836/Fix clean_jobs missing --namespace flag causing BackoffLimitExceeded #837 is working (the old delete-rabbitmq-queues job was successfully deleted before the upgrade), but the newly-created hook job itself is failing at runtime — indicating a transient issue (e.g. RabbitMQ not yet ready when the post-upgrade hook runs)
  • This PR converts deploy_to_doks_from_chartmuseum from a prerequisite chain to a recipe with retry: if the first helm install attempt fails, it cleans up the failed hook job and retries once

How it works

-$(MAKE) clean_jobs                        # pre-clean stale jobs (soft fail if none)
$(MAKE) helm_install_from_chart_museum ||  # first attempt
  ($(MAKE) clean_jobs &&                   # on failure: clean hook jobs helm left behind
   $(MAKE) helm_install_from_chart_museum) # retry once

The VERSION variable is propagated through recursive $(MAKE) calls automatically.

https://app.circleci.com/agents/gh/codacy/chat/00bf1479-ab69-4124-be64-d1b83cdaf69f

When a post-upgrade helm hook job fails with BackoffLimitExceeded, the
failed job lingers in the namespace. The --atomic flag causes helm to
roll back, leaving the hook job behind. On the next CI run, clean_jobs
removes it before the upgrade, but the hook can fail again transiently.

This change converts deploy_to_doks_from_chartmuseum from a
prerequisite-chain target to a recipe that cleans up and retries the
helm install once if the first attempt fails, covering transient hook
failures (e.g. delete-rabbitmq-queues running before RabbitMQ is ready).

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

The PR successfully implements the requested retry logic for Helm hook failures within the deployment pipeline. No critical logic flaws or security vulnerabilities were identified. The implementation is up to standards according to Codacy analysis. However, there are no automated tests provided to verify the retry permutations (e.g., success on first try, success on retry, or total failure). While the logic is sound, adding explicit logging is highly recommended to ensure transient failures are visible in CI logs.

Test suggestions

  • Verify that a successful first attempt does not trigger the retry logic or the second cleanup.\n- [ ] Verify that a failed first attempt followed by a successful retry results in a successful job completion.\n- [ ] Verify that if both attempts fail, the make target exits with a non-zero status.
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Verify that a successful first attempt does not trigger the retry logic or the second cleanup.\n- [ ] Verify that a failed first attempt followed by a successful retry results in a successful job completion.\n- [ ] Verify that if both attempts fail, the make target exits with a non-zero status.
Low confidence findings
  • The retry logic is implemented directly in the Makefile using shell-based operators (|| and &&). This pattern can hide transient failures in standard CI/CD dashboard views unless the logs are examined manually. Consider if your CI tool has a more native way to handle retries for specific steps for better visibility.

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

Comment thread .do/Makefile
deploy_to_doks_from_chartmuseum: set_cluster_context setup_helm_repos clean_jobs helm_install_from_chart_museum
deploy_to_doks_from_chartmuseum: set_cluster_context setup_helm_repos
-$(MAKE) clean_jobs
$(MAKE) helm_install_from_chart_museum || ($(MAKE) clean_jobs && $(MAKE) helm_install_from_chart_museum)

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: Add a log message to signal the retry. This improves observability in CI logs when the initial install fails due to hook jobs.\n\nsuggestion\n\t$(MAKE) helm_install_from_chart_museum || (echo "Helm install failed, retrying after cleaning jobs..." && $(MAKE) clean_jobs && $(MAKE) helm_install_from_chart_museum)\n

Comment thread .do/Makefile
.PHONY: deploy_to_doks_from_chartmuseum
deploy_to_doks_from_chartmuseum: set_cluster_context setup_helm_repos clean_jobs helm_install_from_chart_museum
deploy_to_doks_from_chartmuseum: set_cluster_context setup_helm_repos
-$(MAKE) clean_jobs

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

Nitpick: The hyphen prefix is redundant as the 'clean_jobs' target already handles potential errors internally.\n\nsuggestion\n\t$(MAKE) clean_jobs\n

@ricardobernardino2024
ricardobernardino2024 merged commit b6dec04 into release-17.0.0 Sep 1, 2026
9 checks passed
@ricardobernardino2024
ricardobernardino2024 deleted the chunk/retry-helm-install-on-hook-failure branch September 1, 2026 00:16
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