Registry Mirror
Skip to content

Conversation

@Nishanth29

@Nishanth29 Nishanth Kotla (Nishanth29) commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Under load, a microVM checkpoint or restore can fail because cloud-hypervisor is slow to answer its api-socket. Nothing has changed at that point that a retry can't redo, but the worker returns a plain error and ateapi crashes the actor. We saw this crash an actor on an untuned node under snapshot load (restore: VMM api-socket not ready after 15s).

Part of #3046

  • Checkpoint: WaitReady now runs before tunnel.Deactivate, so a failed wait leaves the actor serving. A WaitReady timeout returns Unavailable while the worker still tracks a running VMM and the checkpoint deadline has not passed.
  • Restore: LaunchVMM and RestoreWithNetFDs timeouts and transient api-socket errors return Unavailable. The existing defers stop the VMM and undo host state. Errors CH itself returns, other socket errors, and a CH that exited during vm.restore stay Internal.
  • ch.WaitReady's timeout error matches the new ch.ErrNotReady.

This builds on #2744 (restore) and #3123 (checkpoint), which keep Unavailable through atelet.

AI use: AI-assisted, I reviewed and tested it.

  • Tests pass
  • Docs updated

@Nishanth29

Copy link
Copy Markdown
Contributor Author

Haowei Cai (Roy) (@roycaihw) could you take a look? It covers the restore steps before resume that #2744 doesn't, plus the checkpoint side.

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.

LGTM

Comment thread cmd/ateworker-microvm/restore.go Outdated
slog.String("mode", memMode), slog.String("vmm_version", client.Info().Version))
if err := client.RestoreWithNetFDs(ctx, restoreDir, restoredNets, memMode); err != nil {
return fmt.Errorf("while restoring VM with net FDs: %w", err)
return restoreVMMError(ctx, "restoring VM with net FDs", err)

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.

🤖 should-fix 🟡 – A cloud-hypervisor that exits is retried here. If CH dies during vm.restore, for example on a corrupt memory image, the client reads EOF and isVMMTransportError returns true. The comment on restoreVMMError says that case stays Internal. The launch call above has the same gap: a CH that exits at startup times out as ch.ErrNotReady. atelet gives up after maxConsecutiveRetryableRestoreFailures, so the cost is two extra restore attempts. The checkpoint side already checks vmmRunning. Checking chProc.Done() here would match it.

@Nishanth29 Nishanth Kotla (Nishanth29) Dec 2, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I checked both paths. During vm.restore, a CH that exits shows up as EOF or ECONNRESET, which isVMMTransportError treats as retryable, so I'll check chProc.Done() there and keep an exited CH as Internal. For the launch case, chProc is already stopped by the time restore.go sees the error, so the fix would go in LaunchVMM, which cold boot also uses. I'd like to keep this PR to the restore path and fix launch in a follow-up, if that's OK.

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.

That sounds reasonable to me. Let's ensure that's tracked in a followup issue. Max Smythe (@maxsmythe) WDYT?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Tracked in #4300.

// wait leaves the actor serving and the checkpoint can be retried.
if _, err := client.WaitReady(ctx, 10*time.Second); err != nil {
return nil, fmt.Errorf("while waiting for CH api-socket: %w", err)
return nil, checkpointWaitReadyError(ctx, ra, err)

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.

🤖 question 🟢 – What bounds the retries when the VMM is alive but never answers? Each attempt now returns Unavailable, and ateapi does not crash the actor on Unavailable. atelet caps restore retries with boundRetryableRestoreError, but I found no equivalent for checkpoint. Before this change the actor crashed on the first failure.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Nothing bounds it today. atelet passes Unavailable straight through for CheckpointWorkload, and ateapi keeps the actor in SUSPENDING, so a VMM that's alive but never answers would fail every retry until it exits or the actor is deleted. Should I add a cap in atelet like boundRetryableRestoreError in this PR or as a follow-up?

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.

Let's add the cap. Leaving an actor stuck indefinitely is a regression

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

While cross-checking this before adding it, I found that a cap in atelet like boundRetryableRestoreError would also cap an unreachable worker, which #3123 left uncapped on purpose so a drain doesn't crash the actor and lose its state.

Two ways to do it:
A) Cap any Unavailable from CheckpointWorkload at 3 in atelet, like restore. Simple, but an unreachable worker would also crash the actor after 3 tries, and TestCheckpointKeepsWorkerUnavailable would change.
B) Cap only the "VMM alive but not answering" case in the microVM worker, so an unreachable worker keeps retrying as #3123 intended.

Which do you prefer? cc Max Smythe (@maxsmythe) Aditya Shantanu (@aditya-shantanu)

Fidelity: ateworkerpb.SnapshotFidelity_SNAPSHOT_FIDELITY_MEMORY,
}

ctx, cancel := context.WithTimeout(t.Context(), 200*time.Millisecond)

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.

🤖 should-fix 🟡 – The 200ms deadline can flake the "VMM answering" row. If the ping has not returned by then on a loaded runner, the call fails before Deactivate and the row reports deactivated = false. That row could use t.Context() directly, since it ends at the panic. The "VMM not answering" row fails on the context deadline, so no test drives CheckpointWorkload to the Unavailable return.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I ran it: the "VMM not answering" row stops on the 200ms deadline and never reaches the Unavailable return. I'll remove the 200ms deadline and make that row actually reach Unavailable.

defer cancel()
var err error
deactivated := func() (panicked bool) {
defer func() { panicked = recover() != nil }()

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.

🤖 nit 🟢 – Any panic counts as reaching Deactivate. A nil dereference elsewhere in CheckpointWorkload would pass the "VMM answering" row. Checking that the recovered value is a nil pointer dereference, or giving the service a Tunnel the test can observe, would make the signal specific.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed that any panic is too broad. A nil-pointer check would still match other nil fields, and the tunnel is a concrete type, so I'll make the row check that the panic came from Deactivate itself.

@@ -0,0 +1,178 @@
//go:build linux

// Copyright 2026 Google LLC

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.

🤖 should-fix 🟡 – This header fails hack/verify/boilerplate.sh on current main, which requires Copyright 2026 The Agent Substrate Authors. I merged main into this head locally and the verifier reported this file. The branch dates from October 29 and needs a rebase.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll rebase onto main and update the header to The Agent Substrate Authors.

Comment thread cmd/ateworker-microvm/restore.go Outdated
if errors.Is(err, ch.ErrNotReady) {
return true
}
var opErr *net.OpError

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.

🤖 nit 🟢 – Matching every *net.OpError makes most of the list below unreachable. ECONNREFUSED, ECONNRESET, EPIPE and os.ErrDeadlineExceeded all arrive from the socket wrapped in an OpError. It also retries failures that will repeat, such as EINVAL from WriteMsgUnix. Keeping only the explicit list would be narrower.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Right, those errors all arrive wrapped in *net.OpError, and it also matches things like EINVAL. Dropping it breaks the "nobody on the socket" row, which gets ENOENT, so I'll drop it and change that row to a socket that refuses the connection.

// been touched yet, so a retry is safe. A VMM that exited stays an internal
// error, since watchVM reports that crash, and so does the caller's context
// ending.
func checkpointWaitReadyError(ctx context.Context, ra *runningActor, err error) error {

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.

🤖 nit 🟢 – The comment says the caller's context ending is reported, but ctx comes from ateworker.CheckpointContext, which drops the caller's cancellation and keeps only its deadline. The "caller gone" test row passes context.Canceled, which this call site cannot produce.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Right, CheckpointContext keeps only the deadline. I'll fix the comment and change that test row to DeadlineExceeded.

… retry

A checkpoint whose VMM api-socket didn't answer in time, or a restore whose
new VMM didn't answer or whose api-socket failed during vm.restore, failed
with an internal error and crashed the actor, though nothing had changed that
a retry couldn't redo. The worker now reports these as Unavailable, and a
checkpoint reaches the VMM before it deactivates the actor's networking.

Signed-off-by: Nishanth Kotla <nishanthkotla@google.com>
…t.go

Signed-off-by: Nishanth Kotla <nishanthkotla@google.com>
Signed-off-by: Nishanth Kotla <nishanthkotla@google.com>
Signed-off-by: Nishanth Kotla <nishanthkotla@google.com>
Signed-off-by: Nishanth Kotla <nishanthkotla@google.com>
… test

Signed-off-by: Nishanth Kotla <nishanthkotla@google.com>
…t test

Signed-off-by: Nishanth Kotla <nishanthkotla@google.com>
@Nishanth29

Copy link
Copy Markdown
Contributor Author

Pushed fixes for all the review comments in f72583c, a2dde8c, 3e96a6e, ce3feb5, d9f85af and 3dffc21 (launch case tracked in #4300); the checkpoint retry cap is waiting on the A/B question above.

This branch has not been deployed

No deployments
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.

3 participants