fix(k8s): diagnose the failed deployment before the rollback deletes it - #214
Open
ignacioboud wants to merge 1 commit into
Open
fix(k8s): diagnose the failed deployment before the rollback deletes it#214ignacioboud wants to merge 1 commit into
ignacioboud wants to merge 1 commit into
Conversation
print_deployment_error_hints ran as the last step of the rollback workflow, after `delete deployment` had already removed the pods it inspects (kubectl get pods -l deployment_id=$DEPLOYMENT_ID). With no pods to read, the specific diagnosis was always empty, and the script's fallback for "nothing detected" printed the generic "Application Startup Issue Detected" block on every rollback — including manual ones where nothing had failed to start. Move the step ahead of the deletion. The failed deployment's pods are still present there under both strategies: scale_deployments is a no-op for blue/green, and for rolling build_context floors green replicas at MIN_REPLICAS precisely so a 0% traffic switch does not remove them. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Every rollback ended with the same block, regardless of what happened:
Including manual rollbacks of applications that started perfectly well.
Cause
print_deployment_error_hintswas the last step ofrollback.yaml, running afterdelete deployment. The diagnosis it performs reads the failed deployment's pods:Those pods were deleted two steps earlier, so the query always came back empty. With no
FAILURE_REASON,SUGGESTED_FIXstayed empty, and the script's fallback for "nothing detected" printed the generic block:The specific diagnosis — image pull errors, crash loops, OOM kills, failed health checks, each with a targeted suggested fix — could never run in a rollback.
Change
Move the hints step ahead of the deletion. One step reordered, no script changes.
The failed deployment's pods are still present at that point under both strategies:
scale_deploymentsis a no-op; its entire body sits insideif [ "$DEPLOY_STRATEGY" = "rolling" ].build_context:115floors green replicas atMIN_REPLICASafter the traffic-based calculation, with the comment "Apply minimum after the blue replica calculation so we do not remove pods with 0% traffic switch".Not addressed here
A manual rollback of a healthy deployment will still reach the generic block, because "nothing detected" and "nothing was wrong" are indistinguishable to the fallback. Separating them means changing the shared script's contract —
wait_deployment_activesources it on deploy timeout, where the generic hints are the right output. That deserves its own change.Tests
k8sBATS suite green (38 tests). Workflow YAMLs have no unit tests in this repo; the file was validated by parsing it and asserting the resulting step order.🤖 Generated with Claude Code