Skip to content

Release machine leases when the context is already canceled - #5311

Merged
dangra merged 1 commit into
masterfrom
fix-lease-release-canceled-ctx
Oct 19, 2026
Merged

dangra merged 1 commit into
masterfrom
fix-lease-release-canceled-ctx

Conversation

@alexleventer

Copy link
Copy Markdown
Contributor

Change Summary

What and Why:

leasableMachine.ReleaseLease is 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 gets lease currently held by ….

How:

The timeout is now built from context.WithoutCancel(ctx), the same approach internal/machine/lease.go already uses.

I added TestReleaseLease_CanceledContext, which fails without the fix. internal/machine and internal/command/deploy tests 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

  • Fresh Produce
  • In superfly/docs, or asked for help from docs team
  • n/a

🤖 Generated with Claude Code

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>
@dangra
dangra merged commit 3af52f2 into master Oct 19, 2026
23 checks passed
@dangra
dangra deleted the fix-lease-release-canceled-ctx branch October 19, 2026 13:36
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.

2 participants