Skip to content

[live-migration] harden resume against stdio and exit wait loss - #2866

Merged
Harsh Rawat (rawahars) merged 4 commits into
microsoft:mainfrom
rawahars:source-rollback-reconnect
Aug 13, 2026
Merged

[live-migration] harden resume against stdio and exit wait loss#2866
Harsh Rawat (rawahars) merged 4 commits into
microsoft:mainfrom
rawahars:source-rollback-reconnect

Conversation

@rawahars

@rawahars Harsh Rawat (rawahars) commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Two blackout-related gaps in live migration, each restoring behavior the connection drop had broken:

  • Container stdio on source rollback — on rollback the VM resumes on source but the container's stdout/stderr, dropped during blackout, were never restored. Resume now brings those streams back the same way the destination already does, so a rolled-back container keeps streaming its output as if the migration had never been attempted.
  • Process exit reported after blackout — a process reopened on the destination relies on the exit wait its previous owner left outstanding in the guest. If it exited while no bridge was connected that response was lost, so the reopened process waited for an exit that was never reported. Reopen now probes with a short bounded wait: an already-exited process returns its retained exit code immediately, while a still-running one lets the probe time out and the outstanding wait is watched as before.

Testing

Ran live-migration source rollback with a single container and with 10 containers; validated logs stream back on the source.

@rawahars
Harsh Rawat (rawahars) requested a review from a team as a code owner August 9, 2026 09:09
When a live migration rolls back to the source, the VM resumes but the
container's stdout/stderr were dropped during blackout and never restored,
so anything watching the container's output saw it stop for good.

Resume now brings those streams back the same way the destination already
does, so a rolled-back container keeps streaming its output as if the
migration had never been attempted.

Signed-off-by: Harsh Rawat <harshrawat@microsoft.com>
A process reopened on the destination relies on the exit wait its previous
owner left outstanding in the guest. If the process exited while no bridge
was connected, the guest's response to that wait was dropped and never
re-sent, so the reopened process would wait for an exit that is never
reported.

On reopen, probe with a short bounded wait: an already-exited process
returns its retained exit code immediately, while a still-running one lets
the probe time out and the outstanding wait is watched as before.

Signed-off-by: Harsh Rawat <harshrawat@microsoft.com>
@rawahars Harsh Rawat (rawahars) changed the title [live-migration] restore container stdio on source rollback [live-migration] harden resume against stdio and exit wait loss Aug 9, 2026
Comment thread internal/gcs/bridge.go
Signed-off-by: Harsh Rawat <harshrawat@microsoft.com>

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 internal/gcs/process.go
}
resp := &prot.ContainerWaitForProcessResponse{}
if probe, err := p.gc.brdg.AsyncRPC(ctx, prot.RPCWaitForProcess, &req, resp); err == nil {
probe.Wait()

@marma-dev Manish Ranjan Mahanta (marma-dev) Aug 13, 2026

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.

IIUC for a successful migration of an N-container pod, destination Finalize adds ~N × 500 ms, fully serialized, while holding the migration/pod/container locks. Your 10-container test ≈ ~5 s of added resume latency. Because migration.Controller.mu is held throughout, concurrent State()/Cancel()/subscribe calls also block during that window (notably, Cancel can't proceed). Please correct me if that's not the case

The synchronous probe serializes N×500 ms under the finalize locks on every destination resume;
Should we consider running startExitWatch asynchronously (guarding the waitCall/waitResp handoff), or lowering exitProbeTimeoutMs, since the running-process case (the overwhelming majority) always pays the full timeout for no functional benefit

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.

Thanks for the insights! Yes, this would have hampered the perf as containers scaled.
As discussed offline, reducing the timeout to 50ms seems like a good idea since it balances code complexity with the perf. Addressed the same in latest commit.

Signed-off-by: Harsh Rawat <harshrawat@microsoft.com>

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

@rawahars
Harsh Rawat (rawahars) merged commit 036d00e into microsoft:main Aug 13, 2026
33 of 34 checks passed
@rawahars
Harsh Rawat (rawahars) deleted the source-rollback-reconnect branch August 13, 2026 08:56
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