Skip to content

ateworker-microvm: give the guest CRNG reseed 60s on restore - #2743

Merged
Benjamin Elder (BenTheElder) merged 1 commit into
agent-substrate:mainfrom
roycaihw:fix/microvm-reseed-retry
Oct 20, 2026
Merged

Benjamin Elder (BenTheElder) merged 1 commit into
agent-substrate:mainfrom
roycaihw:fix/microvm-reseed-retry

Conversation

@roycaihw

@roycaihw Haowei Cai (Roy) (roycaihw) commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Under bursts of concurrent micro-VM restores on one node, a freshly unpaused guest can take more than 5s to schedule its kata-agent and answer the ReseedRandomDev ttrpc call, even after dialAgentRetry completed the hybrid-vsock handshake. The 5s timeout in reseedGuestCRNG then fails RestoreWorkload and crashes the actor.

This PR gives reseedGuestCRNG a single 60s deadline (reseedTimeout) and adds unit tests in cmd/ateworker-microvm/restore_test.go for the deadline and error propagation. It also adds a reseed duration (the kata-agent dial plus the reseed, the head of wakeup_probe) to the Actor restore phases log, from #2878.

Why 60s rather than 15s (from Davanum Srinivas (@dims) in #2878): on a heavily loaded host, the agent dial before the reseed already redials for up to 15s, and the slowest actors take more than 15s from resume to a reseeded guest. The deadline is a cap, not a wait: a healthy guest answers in milliseconds, so 60s costs nothing on the normal path and still fails a dead guest within a minute.

How I tested it

  • go test -race ./cmd/ateworker-microvm/...

  • ./hack/verify/gofmt.sh and ./hack/verify/boilerplate.sh

  • In the 5,000-actor nano-personal-agent micro-VM benchmark campaign, a 15s reseed timeout plus one retry took these crashes from ~1 in 500–1,000 restores to 0 in later runs.

  • From ateworker-microvm: give the post-restore CRNG reseed 60 s #2878: on a nested-virtualization host, a burst of 64 restores crashed 3 at 5s and ran clean at 60s. On bare metal, 5,976 restores in waves of up to 384 reseeded in 0.00s median and 0.28s max.

  • Tests pass

  • Appropriate changes to documentation are included in the PR

@roycaihw
Haowei Cai (Roy) (roycaihw) force-pushed the fix/microvm-reseed-retry branch 2 times, most recently from d240255 to 1e8cedf Compare October 16, 2026 05:22
@roycaihw

Copy link
Copy Markdown
Contributor Author

@roycaihw

Copy link
Copy Markdown
Contributor Author

cc Walter Fender (@cheftako)

Comment thread cmd/ateworker-microvm/restore.go Outdated
return ch.MemRestoreEager
}

const reseedAttempts = 3

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The description says the campaign went to zero crashes with a 15s attempt plus one retry (up to 30s); this lands 3×5s (15s). Was a single 15s attempt tried? The only thing the retry adds over one longer call is a fresh ttrpc stream, and the agent still processes the abandoned 5s call, so attempt 2 queues behind it. Worth stating in the comment why per-attempt cancellation is preferred over one 15s deadline.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

+1 to this question :-)

@bowei Bowei Du (bowei) added area/microVM area/reliability kind/bug Something isn't working / bugfixes labels Oct 19, 2026
@roycaihw Haowei Cai (Roy) (roycaihw) changed the title ateworker-microvm: retry guest CRNG reseed on restore ateworker-microvm: give the guest CRNG reseed 15s on restore Oct 19, 2026
@roycaihw
Haowei Cai (Roy) (roycaihw) force-pushed the fix/microvm-reseed-retry branch 2 times, most recently from fb045b5 to 769f8d1 Compare October 19, 2026 21:29
@BenTheElder

Copy link
Copy Markdown
Collaborator

cc Davanum Srinivas (@dims)

@BenTheElder

Copy link
Copy Markdown
Collaborator

#2878

Comment thread cmd/ateworker-microvm/restore.go Outdated
// reseedTimeout bounds the guest CRNG reseed. It matches the 15s dialAgentRetry
// gives the kata-agent after resume: under concurrent restores on one node, a
// freshly unpaused guest can take more than 5s to schedule its kata-agent and
// answer, even after the vsock handshake succeeded.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// answer, even after the vsock handshake succeeded.
// reseedTimeout bounds the guest CRNG reseed. It needs to be long enough to handle concurrent reseeds.
// a freshly unpaused guest can take more than 5s to schedule its guest agent and answer, so we choose 3x

Under concurrent restores on one node, a freshly unpaused micro-VM guest can take more than 5s to schedule its kata-agent and answer ReseedRandomDev, even after the hybrid-vsock handshake succeeded, and the 5s timeout then failed the restore and crashed the actor. Give the reseed a single 60s deadline, which covers a resume wave on a heavily loaded host; a healthy guest still answers in milliseconds. Log the reseed duration in the restore phases.

Co-authored-by: Davanum Srinivas <davanum@gmail.com>
@roycaihw Haowei Cai (Roy) (roycaihw) changed the title ateworker-microvm: give the guest CRNG reseed 15s on restore ateworker-microvm: give the guest CRNG reseed 60s on restore Oct 19, 2026

// reseedTimeout bounds ReseedRandomDev. It needs to cover a whole resume wave, not a
// single quiet guest.
const reseedTimeout = 60 * time.Second

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this is REALLY high in substrate land, but I suggest we merge and revisit

@BenTheElder
Benjamin Elder (BenTheElder) added this pull request to the merge queue Oct 19, 2026
@cheftako

Copy link
Copy Markdown
Contributor

/lgtm

Merged via the queue into agent-substrate:main with commit 63f875b Oct 20, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/microVM area/reliability kind/bug Something isn't working / bugfixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants