Mark a worker that exits 0 as Completed instead of recreating it forever#181
Merged
Conversation
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
A worker container that exits 0 (a successful, clean exit) was treated as a crash and recreated every reconcile tick, forever.
classify_exit_codemapped0toRetry, soapply_unexpected_exitsbumpedrestart_countand the scheduler recreated the container — which, under the defaultimage_pull_policy: Always, re-pulled the image each time.In production this manifested as a one-shot
pg_dump-style container (declared as a worker) looping endlessly: pull image → run → exit 0 → recreate → pull → ... Each iteration did a full image pull plus the dump, saturating the reconcile cycle. Because all deployments of a namespace reconcile together, this starved every other deployment in thekemeternamespace (Grafana among them) of timely reconciliation.Fix
Treat exit code
0as terminal Completed, never retryable:classify_exit_code(Some(0))now returnsTerminal(Completed).apply_unexpected_exitsshort-circuits a clean exit toCompletedwithout incrementingrestart_count, so the container is never recreated.A worker that finished successfully converges to
Completed(which the scheduler excludes from reconciliation) instead of looping. Non-zero exits keep their existing retry/fast-fail behaviour (126/127 still fail fast; generic 1, signal kills, and unknown codes stay retryable).Verification
Deployed to production and confirmed the loop stops:
creatingPlus a unit test (
clean_exit_completes_without_restart) reproducing the loop: a container exiting 0 lands onCompletedwithrestart_countuntouched. Full suite green,cargo fmt/clippyclean.