Repository navigation
Release machine leases when the context is already canceled - #5311
Merged
Merged
Conversation
ReleaseLease gives itself 500ms to release a lease after the command's context is canceled (e.g. Ctrl-C), but it derived that timeout from the canceled context, so the release always failed immediately and the lease was held until its TTL expired. Derive it from context.WithoutCancel, as internal/machine/lease.go already does. Co-Authored-By: Claude Opus 5.5 <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.
Change Summary
What and Why:
leasableMachine.ReleaseLeaseis meant to give itself 500ms to release a lease after the command's context has been canceled, for example by Ctrl-C. But it built that timeout from the canceled context, so the child context was already canceled, the release failed immediately, and the machine stayed locked until its lease TTL ran out. A user who hits Ctrl-C mid-deploy and runs another command then getslease currently held by ….How:
The timeout is now built from
context.WithoutCancel(ctx), the same approachinternal/machine/lease.goalready uses.I added
TestReleaseLease_CanceledContext, which fails without the fix.internal/machineandinternal/command/deploytests pass.This came out of looking into the "lease currently held" failures in the preflight tests (#5310). The logs don't capture output from commands that passed, so I can't show this bug caused those failures. It's a real bug either way.
Related to: #5310
Documentation
🤖 Generated with Claude Code