Skip to content

nvx: wait for a launch log's claim release with the shared claim wait - #2264

Merged
Pedro Henrique Penna (ppenna) merged 1 commit into
devfrom
agents/issue-2263-claim-release-wait
Nov 27, 2026
Merged

Pedro Henrique Penna (ppenna) merged 1 commit into
devfrom
agents/issue-2263-claim-release-wait

Conversation

@ppenna

Copy link
Copy Markdown
Contributor

Fixes #2263

What does this pull request change?

LockedState::released_claim in nvx/src/host/cli/store/launch.rs bounded its recheck of an interrupted launch's log claim with a literal Duration::from_secs(1). It now waits CLAIM_RELEASE_WAIT, the constant that nvx/src/host/sandbox/scratch.rs already defines, with its rationale, for the same fork-to-exec window of a scratch image's claim, and that the CLI's launch already waits for that claim. The constant's doc comment now also names the launch log's claim, and when a spawned process holds it: through the flock on Linux, and on Windows while the claim is the log's open handles (not the job-based claim). launch.rs drops its now unused Duration import.

Start at released_claim in launch.rs. The change leaves out the follow-ups in #2263: sharing one bounded retry helper between released_claim and the scratch module's until_unclaimed, and naming the century literal in Deadline::instant.

Why is this change needed?

Two waits bounded the same window, the time that a process which another thread of the caller spawns holds an inherited copy of a claim before it executes its program, but only one stated why it lasts one second. With one named constant, the reason is stated once and the two waits cannot drift apart. The value stays one second and the expression keeps its form (deadline.min(Instant::now() + WAIT)), so recovery waits exactly as long as before. Both modules build only with the cli feature, on every target, so the import adds no gating. I chose reusing the existing constant over adding a second constant with the same value and rationale.

How was this change validated?

Checks and results:

  • Affected unit tests, before and after, on Windows: cargo test --locked --all-features --lib -- host::cli::store host::sandbox::scratch in nvx/: 45 passed, 2 ignored at base 8d47379b460 and at the head; the tests are unchanged.
  • python scripts\local_gates.py --base origin/dev --run on this Windows workstation, with the release nvx built and NVX set: test-changes, markdown-links, test-layout, nvx-format, nvx-lint, nvx-test, nvx-doc, nvx-msrv, and nvx-cli passed. The doc comment's final wording landed during that run, so --only nvx-format nvx-lint nvx-doc --run was rerun at b9ee2fe55cb and passed.
  • python3 scripts/local_gates.py --base origin/dev --run --keep-going at b9ee2fe55cb in a clone in this workstation's WSL 2 (Linux): test-changes, markdown-links, test-layout, nvx-format, nvx-lint, nvx-test, nvx-doc, nvx-public-api, nvx-msrv, nvx-macos, nvx-guest-binaries-lint, and nvx-guest-binaries-build passed. nvx-cli first stopped at its pip install step because WSL's system Python is externally managed (PEP 668). It was then rerun in full with --only nvx-cli --run from a temporary --system-site-packages venv, where the pinned PyYAML 6.0.3 was already satisfied, and passed.
  • An earlier WSL run of nvx-test, at the first revision of this commit, which differs only in the doc comment, failed once in guest::sys::signal::tests::a_thread_that_blocks_sigpipe_keeps_only_a_signal_that_was_pending while the Windows gates loaded the same machine. That test passed 3 of 3 runs alone both at base 8d47379b460 and at the head, and the full nvx-test gate passed on the rerun above.
  • python scripts/check_test_changes.py --base origin/dev: 0 changes to existing tests.

Backend, host OS, host type, and guest: no configured host was reachable (kvm: azure-intel-kvm-1 to -5 and -7, azure-amd-kvm-1 to -4; whp: azure-intel-whp-1 to -7, -11, -12, azure-amd-whp-1 to -4), so the checks ran locally on Windows and in WSL 2, not on a configured host. No microVM ran: the change keeps the waited value and expression exactly.

Left to CI: the microVM scenarios on kvm, mshv, and whp, and the benchmarks.

Checklist

  • Tests cover the new or fixed behavior, in the layout that
    python3 scripts/check_test_layout.py checks.
  • python3 scripts/check_test_changes.py --base origin/dev lists no change
    to an existing test, or a Changes to existing tests section below
    explains each one.
  • The documentation that the change affects is updated, including
    .github/copilot-instructions.md and the skills when a convention or
    workflow changes.
  • A change to the public API of nvx updates nvx/public-api/ with
    python3 scripts/public_api.py --update.
  • Snapshots, protocols, and on-disk formats stay compatible, or the
    description says how the change versions or migrates them.

LockedState::released_claim, which rechecks whether a process still
holds an interrupted launch's log claim, bounded the recheck with a
literal one second. The scratch module already names that wait,
CLAIM_RELEASE_WAIT, with its reason: a process that another thread of
the caller spawns holds an inherited copy of a claim from its fork
until it executes its program. The launch log's claim is inherited the
same way: its flock on Linux, and on Windows its open handles when the
log has no job, though not the job-based claim.

released_claim now waits CLAIM_RELEASE_WAIT, whose doc comment also
names the log claim and when it is inherited, so one constant bounds
both waits. The value stays one second and the expression keeps its
form, so recovery waits exactly as long as before. Both modules build
only with the cli feature.

The store and scratch unit tests pass unchanged at 8d47379 and
after the change on Windows: 45 passed, 2 ignored.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 27, 2026 11:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the shared claim-release wait change.

No open issues 🎉

What changed in this PR

Addresses #2263 by sharing the existing claim-release wait between interrupted launch-log recovery and scratch-image checks. The wait remains one second, preserving recovery behavior.

Changes:

  • Replace the launch recovery timeout literal with CLAIM_RELEASE_WAIT and remove the unused Duration import.
  • Expand the constant’s documentation to cover launch-log claims on Linux and Windows.
File Description
nvx/​src/​host/​sandbox/​scratch.rs Document the shared wait’s use for launch-log claims.
nvx/​src/​host/​cli/​store/​launch.rs Use the shared constant and update its documentation reference.

Review effort: Balanced

@ppenna
Pedro Henrique Penna (ppenna) added this pull request to the merge queue Nov 27, 2026
Merged via the queue into dev with commit 6bbb10d Nov 27, 2026
56 checks passed
@ppenna
Pedro Henrique Penna (ppenna) deleted the agents/issue-2263-claim-release-wait branch November 27, 2026 18:42
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.

nvx: wait for a launch log's claim release with the shared claim wait

2 participants