Skip to content

feat: surface critical dockerd and sysbox output in startup logs - #182

Draft
robo-coderai wants to merge 10 commits into
mainfrom
robo/core-423-surface-critical-dockerdsysbox-child
Draft

robo-coderai wants to merge 10 commits into
mainfrom
robo/core-423-surface-critical-dockerdsysbox-child

Conversation

@robo-coderai

@robo-coderai robo-coderai commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

When dockerd or sysbox fails at startup, the cause is only written to the envbox container's logs. In a recent incident dockerd exited with failed to start daemon: ... mkdir /var/lib/docker/100000.100000/tmp: no space left on device, but the workspace startup logs only showed Failed to create Container-based Virtual Machine: kill cmd: kill proc: os: process already finished, so the cause was only visible through kubectl logs.

Child process output that matches a short list of actionable failures is now sent to the workspace startup logs, prefixed with the process name, and logged at error level in the container's logs. The list covers no space left on device, dockerd's failed to start daemon, sysbox-mgr and sysbox-fs startup failures, and level=fatal. Other child output still only goes to the container's logs.

  • Forwarded lines use info level in the startup logs. A match does not mean envbox failed, since envbox can still recover (for example, by restarting dockerd with the vfs driver), and error records are kept for envbox's own failures.
  • Forwarding runs on its own goroutine, so a slow Coder connection never blocks the child's output.
  • Each process run forwards a line at most once and at most 10 lines.
  • A process exit is not reported until its matched lines are sent (bounded at 5s), so the cause appears before envbox's own failure message.

The misleading kill proc: os: process already finished message comes from a separate bug: Restart fails on a dockerd that has already exited, so the vfs fallback never runs. That fix will be a follow-up PR.

Testing: unit tests in background/process_test.go use real sh processes. A new integration test, TestDocker/CriticalOutputInStartupLogs, gives dockerd a 64 KiB tmpfs data root and checks that the no space left on device line reaches a fake Coder before the failure message. It uses a new CreateDockerCVMConfig.OuterTmpfs option, because dockertest's TempfsOptions serializes under the wrong JSON key and Docker ignores its size limit. The test harness now treats envbox exiting without a done record as a failed start instead of failing the test, because this failure path exits without an error record.

Note

The CI integration job never sets CODER_TEST_INTEGRATION, so TestDocker skips in CI today. This branch enabled it temporarily, with -v, and the full integration suite passed, including CriticalOutputInStartupLogs (run), then reverted it. Enabling it permanently is probably worth a separate PR.

Refs:
https://linear.app/codercom/issue/CORE-423

🤖 Generated with Claude Code

robo-coderai and others added 2 commits November 24, 2026 19:27
dockerd and sysbox failures were only written to the envbox container's
logs. For example, when dockerd ran out of disk at startup, the workspace
startup logs only showed a later, misleading error.

Child process lines that match a short list of actionable failures (no
space left on device, dockerd and sysbox startup failures, logrus fatal)
are now logged at error level and forwarded to the workspace startup
logs. Forwarding runs off the output path so it never blocks the child,
is deduplicated and capped per process run, and completes before the
process exit is reported so the cause appears before envbox's own
failure message.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Temporary commit so CI exercises the new integration test. The job never
sets CODER_TEST_INTEGRATION, so TestDocker and TestDocker_Nvidia skip.
Drop before marking the PR ready.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@linear-code

linear-code Bot commented Nov 25, 2026

Copy link
Copy Markdown

CORE-423

robo-coderai and others added 8 commits November 25, 2026 19:43
…artupLogs

docker.TempfsOptions serializes as "TempfsOptions", but the Docker API
expects "TmpfsOptions", so the 64 KiB limit was dropped and dockerd
started normally. Add CreateDockerCVMConfig.OuterTmpfs, which sets
HostConfig.Tmpfs, and use it for /var/lib/docker.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CI passed with TestDocker enabled (run 45687984937), so the temporary
change is no longer needed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A matched dockerd or sysbox line does not mean envbox failed, since envbox
can recover by restarting dockerd with the vfs driver. Writing it with
blog.Errorf emitted JSON error records, which until now meant envbox gave
up. Write it at info level instead.

Copy ctx, binName, and the handler into locals in startProcess so its
goroutines no longer race with Restart reassigning those fields.

Make the integration test wait for both the dockerd line and the failure
message, then always assert their order. Previously the check was skipped
when the failure message had not arrived yet. waitForCVM now reports
failure when envbox exits without a done or error record, since this
failure path ends in log.Fatal after info-level messages only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Temporary commit so CI exercises the new integration test. The job never
sets CODER_TEST_INTEGRATION, so TestDocker and TestDocker_Nvidia skip.
Drop before marking the PR ready.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Temporary, to confirm which TestDocker subtests run. Reverted with the
CODER_TEST_INTEGRATION commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant