Skip to content

fix: 🐛 Allow sandbox worker to reconnect after stall - #841

Merged
pdettori merged 2 commits into
rossoctl:mainfrom
evaline-ju:sandbox-worker
Nov 17, 2026
Merged

pdettori merged 2 commits into
rossoctl:mainfrom
evaline-ju:sandbox-worker

Conversation

@evaline-ju

Copy link
Copy Markdown
Contributor

Summary

After a stalled connection, a sandbox worker reconnected but left its old stream open. The relay refused the reconnect as a duplicate, and the sandbox stopped running commands until the worker restarted.

Each connection attempt now closes its stream before the worker reconnects, in both the container and microVM workers.

Closes: #839

Assisted-By: Claude (Anthropic AI)

Checklist

  • Commits are signed off (git commit -s).
  • make lint and the tests for the touched packages pass.
  • Docs: changed behavior, flags or environment variables are reflected in the relevant README or
    docs/ page, with the right maturity label (see docs/CONTRIBUTING-DOCS.md).
  • Docs: make check-links passes if any Markdown changed.
  • A new spec or ADR is registered in docs/specs/README.md or docs/adrs/README.md. - N/A

@evaline-ju
evaline-ju requested a review from pdettori as a code owner November 16, 2026 22:39
@evaline-ju evaline-ju added the ready-for-ai-review Request automated AI code review from clawgenti label Nov 16, 2026

@clawgenti clawgenti left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Summary

Solid fix for the stalled-reconnect bug: wrapping each attach/serve attempt in its own cancellable context correctly tears the stream down before the re-dial in both the container and microVM workers, and the two new tests demonstrate the relay-side effect (Gone()) empirically rather than just asserting a cancelled context. No blocking findings.

Author: evaline-ju (CONTRIBUTOR — returning external)
Areas reviewed: Go (remote-worker), tests, docs spec
Agent/IDE config (.claude/.vscode): none
Commits: 2 commits, all signed-off: yes
CI status: passing (check, lint, shellcheck, k8s-kind-e2e, CodeQL, Trivy)

Nit (advisory, non-blocking): both commit subjects use an emoji prefix (:bug:, :bulb:) rather than a conventional prefix (fix:, Docs:); the PR title itself is fine. Consider fix:/docs: prefixes on future commits — DCO is the only enforced check.

Verified against the diff: serveOnce/attachOnce return zero duration on attach failure, so backoff reset behavior is unchanged from the previous if err == nil structure; Serve's documented precondition (receiving the stream's own context) is preserved in both workers.

Generated by RepoMan github-pr-review@235a7f7 (https://github.com/rossoctl/agent-skills/blob/235a7f7620139ee3e4ab0872b8439591fe52e8c1/skills/github-pr-review/SKILL.md).

@clawgenti clawgenti left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Follow-up to the review above (bot bookkeeping — no new findings): the fix and tests look good as reviewed.

Generated by RepoMan github-pr-review@235a7f7 (https://github.com/rossoctl/agent-skills/blob/235a7f7620139ee3e4ab0872b8439591fe52e8c1/skills/github-pr-review/SKILL.md).

@ingpaolodettori-dev ingpaolodettori-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM. The per-attempt context in attachOnce / the new serveOnce makes every return from Serve close the stream before the re-dial. That covers ErrEgressWedged and also the other in-loop error returns (accept/leaseControl refusals). Serve still gets the context its stream was created from, as loop.go's precondition requires. rotateWhenIdle's inner stream context derives from the attempt context, so the cancel reaches it, and SIGTERM still flows through the parent ctx. The container-worker test against relaytest checks the server-side stream really ends, which is the property that matters.

Assisted-By: Claude Code

@pdettori
pdettori merged commit e13a253 into rossoctl:main Nov 17, 2026
17 checks passed
@pdettori pdettori added this to the v0.11.0 milestone Nov 17, 2026
webchang added a commit to webchang/moca that referenced this pull request Nov 17, 2026
Takes upstream main at 1a7f41e (19 merges since 032c8f6): the sandbox
idle lifetime across docs, control plane, clients and deploy (rossoctl#820, rossoctl#837,
rossoctl#842, rossoctl#843), grant redemption (rossoctl#822), the lease-check log line (rossoctl#824),
egress fixes (rossoctl#829, rossoctl#834), the mock wait (rossoctl#828), the deadline timer
(rossoctl#835), the create rollback (rossoctl#832), multi refusals and the rossoctl#363 leftovers
(rossoctl#833, rossoctl#838), the identity near-miss check (rossoctl#827), mocactl login errors
(rossoctl#836), the ghostunnel probes (rossoctl#830), refusal-burst deferral (rossoctl#831), a
sandbox-worker change (rossoctl#841) and the v0.11 doc truth (rossoctl#821).

Conflicts (one):

- deploy/sbx/README.md, the "Optional inputs" table. Upstream (rossoctl#843)
  rewrote the SBX_LIFETIME_DAYS row (the default idle lifetime, at most
  SBX_MAX_LIFETIME_DAYS) and added the SBX_MAX_LIFETIME_DAYS and
  SBX_LOWER_WORKSPACE_IDLE rows, which widened the table; the fork had
  added an SBX_GATE_RECORD_SCHEMA row at its end. Resolved by taking
  upstream's table whole and appending the fork's SBX_GATE_RECORD_SCHEMA
  row after SBX_PROFILE, then re-padding the table with prettier. The
  fork's env-file example line for SBX_GATE_RECORD_SCHEMA merged cleanly.

Merged without markers, checked: setup.sh keeps the fork's
SBX_GATE_RECORD_SCHEMA validation and its sbx-settings write (so it stays
in the settings hash) beside upstream's SH_SANDBOX_MAX_LIFETIME_SECONDS;
both ocp-sbx and ocp-combined patch-control-plane.yaml keep the optional
SH_GATE_RECORD_SCHEMA from sbx-settings beside the new optional
SH_SANDBOX_MAX_LIFETIME_SECONDS; setup.test.sh keeps the fork's cases
beside upstream's. The fork's RUNBOOK, README and template-onboarding
docs say nothing about sandbox lifetime, refusal bursts, login errors or
the create rollback, so none needed a correction; GUIDE.md is unchanged
and GUIDE.pdf is not regenerated.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
@evaline-ju
evaline-ju deleted the sandbox-worker branch November 17, 2026 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-ai-review Request automated AI code review from clawgenti

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 Sandbox worker can't reconnect after a stalled connection

4 participants