Skip to content

fix(guest): start applications only after the env update window is closed - #1546

Merged
kvinwang merged 1 commit into
feat/kms-epochs-combinedfrom
fix/sealed-env-window-fail-closed
Nov 9, 2026
Merged

kvinwang merged 1 commit into
feat/kms-epochs-combinedfrom
fix/sealed-env-window-fail-closed

Conversation

@kvinwang

@kvinwang kvinwang commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

The env update window closed only through two best-effort messages: the guest's UpdateSealedEnv, which only logged a warning on failure, and the application-stage boot.progress notifications (|| true). If both were lost, application code could replace the env the next boot reads. Closing the window is now an acknowledged step, and the boot fails closed without the acknowledgment.

  • VMM: closes the window as soon as it identifies the VM, then always succeeds; a reason the env was not stored (window already closed, no SealedEnv support, env changed since boot) is logged. Only failures before closing (an unknown VM) are errors.
  • Guest: continues once answered, or when there is no window: no host API, another platform, or a VMM predating UpdateSealedEnv. Other errors are retried after 1, 2, 4 and 8 s; if none is answered, the boot fails before init scripts or containers run. A retry after a lost answer finds the window closed and continues, as does a reboot inside the same VM process.
  • Old VMMs: recognized by status, not by our error text. A VMM since 0.6 answers an unknown method with 404; before 0.6 it answered 400 with the pRPC dispatcher's fixed Service not found: <method>. PrpcClient now carries non-200 answers as StatusError { status, message }; its Display is unchanged.
  • Unchanged: the boot.progress closing stays as defense in depth, and a VM the VMM adopts already running still gets no window.

Tests:

  • dstack-util: 133 passed. Covers the retry loop (answered, a lost answer retried, no answer failing the boot) and HostApi against a fake host: 200, both old-VMM unknown-method answers, other 400, 500, refused, and no host API.
  • dstack-vmm: 229 passed. Exercises the guest's own HostApi against the real handler: the window closes on the first answer, rejected and late updates still close it without storing, and an unknown VM errors.
  • http-client: 12 passed.
  • cargo fmt is clean, and clippy on non-test code is clean.

kvinwang added a commit that referenced this pull request Nov 9, 2026
…tation

DiskMigration now models the two-keyslot migration of #1539 (luksAddKey,
token bound to its keyslot, luksKillSlot) instead of luksHeaderRestore, and
lets the KMS rotate at any point of a boot. All invariants hold for epochs
0-3; the torn-restore script and the configs for the replaced scheme go.

KmsRotation checks the latest registered epoch's chain hash on handover, as
onboard_service.rs does since #1542, so HandoverAgreesWithRegistry now holds
and joins the main config.

EnvUpdate gains FailClosed for the guest of #1546, which holds with a lossy
host API; the lossy config keeps the earlier guest as a counterexample.

The README records the mutations each model catches.

Signed-off-by: Kevin Wang <wy721@qq.com>
…osed

The VMM closes a boot's env update window when the guest calls
UpdateSealedEnv or reports an application-stage boot.progress. Both
were best effort: a failed UpdateSealedEnv only logged a warning and
the progress notifications ignore errors. If both were lost, the
window stayed open and init scripts or containers could replace the
env the next boot reads.

Make closing the window an acknowledged step:

- The VMM closes the window as soon as it identifies the VM and then
  always succeeds, logging why an env was not stored. Only failures
  before that point (an unknown VM) are errors.
- The guest continues once answered, or when the host has no window: no
  host API, another platform, or a VMM predating UpdateSealedEnv,
  recognized by its unknown-method status (404 since 0.6, 400 with the
  pRPC dispatcher's "Service not found" before). Other errors are
  retried with backoff, and the boot fails if none is answered.
- The pRPC client reports a non-200 answer as a StatusError carrying
  the status, so the guest needs no text matching for new VMMs; its
  message is unchanged.

A retry after a lost answer finds the window closed, as does a reboot
inside the same VM process. The boot.progress closing stays as defense
in depth.

Signed-off-by: Kevin Wang <wy721@qq.com>
@kvinwang
kvinwang force-pushed the fix/sealed-env-window-fail-closed branch from 2da8459 to ff136ad Compare November 9, 2026 15:09
@kvinwang
kvinwang merged commit d1608cd into feat/kms-epochs-combined Nov 9, 2026
1 check passed
@kvinwang
kvinwang deleted the fix/sealed-env-window-fail-closed branch November 9, 2026 15:12
kvinwang added a commit that referenced this pull request Nov 9, 2026
…tation

DiskMigration now models the two-keyslot migration of #1539 (luksAddKey,
token bound to its keyslot, luksKillSlot) instead of luksHeaderRestore, and
lets the KMS rotate at any point of a boot. All invariants hold for epochs
0-3; the torn-restore script and the configs for the replaced scheme go.

KmsRotation checks the latest registered epoch's chain hash on handover, as
onboard_service.rs does since #1542, so HandoverAgreesWithRegistry now holds
and joins the main config.

EnvUpdate gains FailClosed for the guest of #1546, which holds with a lossy
host API; the lossy config keeps the earlier guest as a counterexample.

The README records the mutations each model catches.

Signed-off-by: Kevin Wang <wy721@qq.com>
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.

1 participant