Repository navigation
feat(daemon): opt-in bounded FIFO queue for a foreign device lease (#1864) - #1873
Merged
Merged
Conversation
A competing workflow can now queue for a board instead of failing fast: `fbuild deploy --lease-wait <seconds>` joins a per-port FIFO and proceeds in ticket order once the holder releases. - DeviceManager gains enqueue_waiter/leave_queue/poll_admission and the bounded await_admission; admission is head-of-queue only, so waiters cannot reorder, and the lease holder is never queued. QueueGuard owns the ticket, so a cancelled request leaves the queue. - DeployRequest.lease_wait_ms (serde default 0 = fail fast) and the --lease-wait flag; the wait runs before preemption, reset or open. - New DeviceLeaseError::LeaseWaitTimedOut reports queue position, holder and elapsed wait, and states the board was not reset/closed/flashed. #1864 criterion 3.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
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.
Continues #1864 (criterion 3: "Add an opt-in bounded wait/queue
for competing workflows, with holder/progress diagnostics, cancellation, and
deterministic ordering. Retain fail-fast behavior for callers that do not opt
in. Waiting must occur before preemption/reset/open.").
The first two slices merged as #1869 (deploy/reset admission) and #1871 (serial
write path). Both refuse a foreign exclusive lease immediately; a second
checkout still had to retry in a shell loop. This slice adds the queue.
What changed
DeviceManageradmission queue (device_manager/wait_queue.rs, asibling module so the parent stays under the LOC gate):
enqueue_waiter/leave_queue/queued_client_ids/queued_workflowsover a per-port FIFO keyed by a monotonic sequence number.
poll_admission(port, lease_id, ticket)— the single admission rule:the lease holder is always admitted, an unknown port is admitted (emulator
and probe routes stay outside the lease path, as in fix(daemon): enforce explicit device leases on deploy and reset admission #1869), and a waiter is
admitted only at the head of its port's queue with no foreign lease.
A fail-fast caller (no ticket) is refused while anyone is queued, so two
clients that observe a release in the same instant cannot reorder.
await_admission(port, lease_id, wait_ms, client_id)— the opt-in boundedwait.
wait_ms == 0keeps today's fail-fast behaviour; otherwise thecall joins the queue and polls on a 20 ms → 200 ms backoff until admitted
or the deadline expires.
QueueGuardowns the ticket, so a cancelledrequest (dropped future) leaves the queue and promotes the next workflow
instead of becoming a phantom head-of-line blocker.
DeployRequest.lease_wait_ms(#[serde(default)], so older clients thatnever send it keep fail-fast admission) and
fbuild deploy --lease-wait <seconds>. The wait runs at the same admission site as fix(daemon): enforce explicit device leases on deploy and reset admission #1869 — on theresolved port, before
preempt_for_deploy— so a queued deploy neverresets, closes or flashes the holder's board. The holder deploying under its
own
--lease-idis never queued.DeviceLeaseError::LeaseWaitTimedOutnames the queue position,the holder (lease id, client, description) and the elapsed wait, and states
that the board was not reset, closed or flashed. With
waited_ms == 0itrecommends
--lease-wait/fbuild device take.docs/reference/cli.md"Workflow leases" documents the queue semantics.Tests (real output)
device_manager/tests.rs::lease_wait_queue_tests(8): FIFO head-onlyadmission, foreign-lease head blocking + holder naming, an unqueued caller
cannot jump a waiter, unknown ports admitted, bounded wait admits after a
release (≥100 ms, real
tokio::time), timeout leaves the queue empty,wait_ms == 0stays fail-fast, holder never queued.models.rstests (2):lease_wait_msdefaults to 0, and carries theopt-in value.
AdmissionPoll::Admitted→test result: FAILED. 2 passed; 6 failed(
a foreign lease admitted the waiter, …); restored →ok. 39 passed; 0 failed(cargo test -p fbuild-daemon --lib device_manager).cargo test -p fbuild-daemon --lib→ 317 passed / 0 failed / 3 ignored(baseline was 307/0/3).
soldr cargo clippy -p fbuild-daemon -p fbuild-cli --all-targets -- -D warnings→ rc 0.
cargo fmt --all --check→ rc 0.ci/check_test_layout.py→ ok (8 categories).ci/enforce_platform_boundary.py --print-totals→rows=44; dylint_rows=43, rc 0 (no host occurrences added;the ledger ratchet is untouched).
Still open on #1864
Lease identity across re-enumeration/recovery reattach, Python facade
lease_id/lease_wait_msplumbing, and the two-real-checkout hardwareturn-taking validation (needs an idle board).