Repository navigation
Bug sweep 3: local connect lock, shutdown and tunnel-client fixes - #378
Merged
Merged
Conversation
There can be at most one connect per machine, but the pre-check only looked at the pidfile of the mode being started. With an unprivileged connect to cluster A running, a privileged `local connect --cluster B` started a root manager whose sandbox manager child failed to take the lock, and the root manager then monitored (and wired root networking to) A's sandbox manager, while connect exited 0. Refs ENG-1248. Co-Authored-By: Claude Opus 5.5 <[email protected]>
If the sandbox manager command couldn't be formulated (e.g. the binary was moved or upgraded while connected), sbmgrMonitor.run returned without closing doneAck, so stop() blocked forever and disconnect never restored /etc/hosts, routes/pf or the resolver. Close doneAck on every exit path. Refs ENG-1248. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Disconnect deliberately has no deadline (giving up part way could leave networking in a bad state), but it retried silently forever, e.g. on a stale pidfile whose PID was reused after a hard power-off. After 5s, and then every 30s, report the wait time, the last shutdown error and the pidfiles/PIDs being waited on. Refs ENG-1248. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The tunnel API client is nil until the link to the cluster is healthy (and forever if it never becomes healthy), and was read by gRPC handlers without synchronisation. - GetResourceOutputs (sandbox get-env/get-files) before the link was healthy called a nil client, crashing the sandbox manager; it now returns Unavailable. - When the link never became healthy (connect timeout, disconnect, SIGTERM), the sandboxes watcher panicked on the nil client before the devbox session was released; the watcher now doesn't start without a client, so shutdown releases the session. - The client is guarded by the watcher's mutex. Refs ENG-1248. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Sep 29, 2026
davixcky
approved these changes
Sep 30, 2026
davixcky
left a comment
Contributor
There was a problem hiding this comment.
LGTM. I built it locally (merged with the rest of the sweep) and compared it with main, using local connect --unprivileged against staging. With a live PID in rootmanager.pid, main connects anyway; this branch refuses with "signadot is already connected". Disconnect/connect otherwise behave the same.
Non-blocking nits:
- The two-pidfile check only covers connects run one after another. It runs before the sudo prompt, so a privileged connect waiting at the password prompt can still race an unprivileged connect for another cluster. The real fix probably belongs in the daemons: the root manager shouldn't adopt a sandbox manager it didn't start. Might be worth saying in the description that only the one-after-another case is fixed.
- The watcher half of
TestNoTunnelAPIClientpasses without the fix. The nil call happens ingo sbw.watchSandboxes(...), and the test returns before it panics. disconnectwith a stale pidfile still loops forever. It now names the pidfile, which helps, but it doesn't say to remove it. The "already connected" error could also say which mode or pidfile is blocking.
Brings in origin/main via the updated base. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Brings in the --attach and locald address fixes from #376's review. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Brings in origin/main via the updated base. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Brings in #377, merged into the base. Co-Authored-By: Claude Opus 5.5 <[email protected]>
scott-cotton
added a commit
that referenced
this pull request
Oct 2, 2026
Fourth batch of CLI bug-sweep fixes (ENG-1248). **Stacked on #376.** It is independent of #377 and #378, and merges cleanly with both. There is one commit per fix; review only the 9 commits here. ## Commits - **`fix(artifact)`**: download to a temp file and rename it into place on success. Before, `artifact download -j wrongjob report.xml` emptied an existing `report.xml` on a 404/401, and failed downloads left partial files. The 4-minute timeout now only limits how long the download takes to start; before, it covered the whole body, so any artifact taking longer than 4 minutes to download failed. - **`fix(sandbox)` get-files**: with the default output directory, `--no-clobber` no longer deletes the directory, and the local edits in it, before the check. - **`fix(sandbox)` apply**: no panic on a file without `spec`, which now returns an error. No panic when `--wait` fails before any successful GET; the applied sandbox is printed instead. - **`fix(secret)`**: the server's update replaces the description (confirmed in `sandboxes/internal/control/secret/update.go` and `appdb.UpdateSecret`), so `secret update NAME --value-file f` wiped it. The CLI now sends the current description unless `--description` is given; an explicit empty value still clears it. With `-f`, the file is still the whole secret. - **`fix(devbox)`**: create `~/.signadot` before `devbox register`. Before, when auth came only from the environment, the devbox was registered on the server and then saving its ID failed with ENOENT. - **`fix(poll)`**: `Readiness.Stop` racing a fatal error could panic with "close of closed channel", e.g. on Ctrl-C during `local override`, before the undo ran, leaving the override middleware on a shared sandbox. `done` is now closed via `sync.Once`. - **`fix(override)`**: the override log server now listens on loopback only. It listened on all interfaces, so anyone on the network could POST `/api/logs` and print spoofed entries to the user's terminal. - **`fix(auth)`**: plaintext credentials are written atomically (temp file + rename), and a file that fails to parse is reported instead of deleted. Before, a read concurrent with login or token refresh could see a partial file and delete the fresh credentials. - **`fix(bug)`**: `signadot bug` printed only the API config, because the embedded `*config.API`'s `MarshalJSON` was promoted. It dropped `BuildInfo` and `Error`, which are what the command is for. The error was also an interface, which marshals as `{}`. **Output shape change:** the API config is now nested under `config`. ## Testing - Each fix has a test. The ones for the artifact download, `sandbox apply` (missing spec), devbox, `poll` (reproduces "close of closed channel") and plaintext credentials were checked to fail without their fixes. Tests use fake API servers where needed. - `go vet ./...` and `go test ./...` pass; `-race` passes for `internal/auth` and `internal/poll`. Refs ENG-1248. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
scott-cotton
added a commit
that referenced
this pull request
Oct 2, 2026
Fifth batch of CLI bug-sweep fixes (ENG-1248), for plans. **Stacked on #376.** It is independent of #377, #378 and #379, and merges cleanly with each. There is one commit per fix; review only the 5 commits here. ## Commits - **`fix(plan): resume live plan logs`**: `plan run --attach` and `plan x logs -f` opened the live stream once and discarded its errors. That caused three problems: - A stream requested before dispatch got a 404 (`execution not yet dispatched to a runner`) and the run showed no logs. - After the server's 5-minute idle cut (`planexecution/logproxy.go`, e.g. a silent step), all later logs were lost. - `--attach` cancelled the stream as soon as a terminal phase was seen, dropping trailing lines. The new `planexec.FollowLiveLogs` reconnects from the last cursor on a 404 before the execution finishes, on 5xx, and on connection/SSE errors. It stops when the stream ends or the execution is finished (the runner no longer holds live logs). `--attach` now gives the stream up to 10s after the execution finishes to deliver the rest. - **`fix(plan): don't truncate --output-dir exports`**: the export used go-openapi's 30s default request timeout, which covers the whole streamed body. Large or slow outputs were truncated, the remaining outputs skipped, and the run still exited 0 with only a warning. Downloads now have no request timeout (the command's context bounds them) and are written atomically. A failed export makes `plan run` exit non-zero after the result is reported. - **`fix(plan): allow compile/recompile to take longer than 30s`**: the server compiles synchronously with an LLM, bounded only by the request context. After 30s the CLI hit its deadline, the server cancelled the compile, and no plan was created. The timeout is now 5 minutes. - **`fix(planexec): dedup step outputs`**: plan outputs were keyed by `<step>/<plan output name>` instead of `<step>/<StepRef.OutputName>`. `plan x outputs` and `get-output --all` listed referenced step outputs twice when the names differed, and hid unrelated step outputs that happened to share the plan output's name. - **`fix(plan): send --param values of string-typed params as strings`**: `python_version=3.10` was sent as a JSON number and reached the plan as `3.1`. If the plan declares the param's JSON Schema `type: string`, the value is now sent as given. Untyped params keep the existing JSON inference, so an untyped `3.10` is still sent as a number; plan authors can type the param to avoid that. ## Testing - `FollowLiveLogs` is tested against a fake server: 404 before dispatch, then a stream cut by an SSE error, then a resume, checking the output and the cursors sent. A separate test checks that it stops with the error once the execution is finished. There are also tests for export (partial failure, no leftover files), output dedup (fails without the fix) and string-schema params. - `go vet ./...` and `go test ./...` pass; `-race` passes for `plan` and `planexec`. - Not yet run against a real plan execution. Refs ENG-1248. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Third batch of CLI bug-sweep fixes (ENG-1248), for
local connect. Stacked on #376 (independent of #377); review only the 4 commits here.Design invariants (see the triage comment on ENG-1248): at most one connect per machine, enforced by the locald pidfiles; disconnect has deliberately no deadline, since giving up part way could leave the machine's networking corrupted.
Commits
fix(local): refuse connect when either local daemon is running: the pre-check only looked at the pidfile for the mode being started. With an unprivileged connect to cluster A running, a privilegedlocal connect --cluster Bstarted a root manager. Its sandbox-manager child failed to take the lock, and the root manager then monitored, and wired root networking to, A's sandbox manager. Connect still exited 0.fix(locald): don't hang root manager shutdown after sbmgr monitor exits: if the sandbox manager command couldn't be formulated (e.g. the binary was moved or upgraded while connected),sbmgrMonitor.runreturned without closingdoneAck.stop()then blocked forever and disconnect never restored hosts, routes/pf or the resolver.fix(local): report what disconnect is waiting on: no deadline added. After 5s, then every 30s, disconnect prints how long it has waited, the last shutdown error and the pidfiles/PIDs it is waiting on. Previously it retried silently forever, e.g. on a stale pidfile whose PID was reused after a hard power-off (IsPIDRunningtreats EPERM as running). Proper staleness detection belongs in libconnectprocesses.fix(locald): handle a missing tunnel API client in the sandbox manager:GetResourceOutputs(sandbox get-env/get-files) before the link was healthy called a nil client and crashed the sandbox manager; it now returnsUnavailable. When the link never became healthy, the sandboxes watcher panicked on the nil client before the devbox session was released; the watcher now doesn't start without a client. The client is now guarded by the watcher mutex.Testing
stop()after a fatalrun()exit, disconnect wait report, and a nil tunnel client (GetResourceOutputs and watcher). ThedoneAckand tunnel-client tests fail without their fixes (timeout / nil-pointer panic).go vet ./...andgo test ./...pass;-racepasses forinternal/locald/...andinternal/command/local.Refs ENG-1248.
🤖 Generated with Claude Code