Repository navigation
Stop an unresolved operation from blocking its own cleanup - #215
Merged
Merged
Conversation
…s own cleanup Found in production: a cancelled session's Pod was still Running 109 minutes after its workflow closed, and the reservation was still held. The two prohibitions were tangled. AD-5 says an operation nobody can prove landed must not release the slot — a late create must never find its seat given away. Cleanup enforced that by refusing to do anything at all, which deadlocked: the workload kept the slot honestly occupied, and the operation could never resolve because the deletion that would have made absence provable was the thing being refused. Deleting the runtime is now separate from releasing the reservation. The stop marker is already set by then, so no new attempt can start; the delete goes ahead, and only the release waits for an operator. If a late create does land, it reappears under the same stable identity, absence stays false and the loop holds the slot — self-correcting, which refusing to delete never was. Reconciliation also used to skip these admissions entirely, which is how one stayed invisible for hours. It examines them like any other now, and relabels a closed workflow's `in_flight` operation as `uncertain`: nothing can report that result any more, and `in_flight` reads as ordinary provisioning load in the health line, so a pinned slot never reached the number an operator watches. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Artem Petrov <[email protected]>
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.
What production showed
A cancelled session's Pod was still
1/1 Running109 minutes after its workflow closed, with the reservation still held:The reservation was held correctly — there was a real container consuming real cluster resources, and AD-6 says capacity is not returned while the workload is confirmed present. The bug is that nothing was deleting it.
The deadlock
Two different prohibitions had been collapsed into one. AD-5 says an operation nobody can prove landed must not release the slot: a late create must never find its seat given away. Cleanup enforced that by refusing to do anything at all:
So:
The guard protecting the capacity accounting prevented the cleanup that would have made the accounting true.
The fix
Deleting the runtime is separate from releasing the reservation. The stop marker is already set by the time cleanup runs, so no new attempt can start; the delete goes ahead, and only the release waits for an operator.
If a late create does land, it reappears under the same stable identity,
session_absent?stays false and the retry loop keeps holding the slot — self-correcting, which refusing to delete never was.Reconciliation stops skipping the wedged ones. It excluded admissions with unresolved operations from its scan, which is exactly how this one stayed invisible for hours. They are examined like any other now.
A closed workflow's
in_flightoperation is relabelleduncertain.in_flightmeans "a create is running right now", which is only true while something is running it. Once the workflow is closed nothing can ever report that result — andin_flightreads as ordinary provisioning load in the health line, so a fully pinned slot showeduncertain_operations: 0for 108 minutes.uncertainis the number an operator is alerted on.Type of change
How was this tested?
docker compose exec -T web make check_all— green in full.Four tests, each pinned to a claim rather than to the implementation: an unresolved operation now deletes but does not release; it still never releases even once the runtime is gone; a closed workflow strands its in-flight operation into
uncertainand that reaches the health snapshot; a wedged admission is examined rather than skipped, and its runtime is deleted.The existing test that asserted the old "refuses everything" behaviour was rewritten rather than deleted — the invariant it guarded (never release) still holds and is still checked.
Checklist
make check_allpasses locally.