Repository navigation
feat(spored): copy a failed job's log tail to the serial console (#736) - #759
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Closes #736's diagnosis gap. When a --command workload failed and the instance self-terminated, /var/log/spawn-command.log went with it. The exit code survived in a tag; the REASON did not. From outside, "the job failed" and "the job failed because the package install 404'd" were the same event. spored now copies the last 50 lines of that log to the serial console before terminating, on a FAILED outcome only. Both facts this depends on are MEASURED, not assumed: - A userspace write to /dev/console does appear in ec2 get-console-output. Probed with a nonce on a real instance. - That output outlives the instance's visibility in describe-instances by hours (12,848 bytes returned for an instance already reporting state=None). - The post-termination capture takes ~4-5 MINUTES to populate, and before that the API returns NOTHING rather than a partial result. The log line says so, because an immediate read looks exactly like a missing log — I made that mistake myself while probing and briefly concluded the whole approach did not work. 50 lines is a budget, not a guess: console output caps around 64 KB and a baseline boot consumes 13-17 KB, so copying a whole log would evict the cloud-init messages that are ALSO diagnostic. Chosen over an S3 upload because it needs no bucket, no IAM grant and no new write path, so it does not enlarge the un-reaped spawn-results-* footprint on every launch. The task path keeps its existing S3 flush (pkg/taskproto/flush.go), unaffected. sysWriteConsole follows the package's existing platform split and is a no-op on Windows and dev builds, where /dev/console does not exist. Cross-compiled for windows/amd64 and linux/arm64 to check that. The failure gate needed no new plumbing: checkCompletion was already reading the completion record just to log it. completionFailed is lenient by design — unparseable, truncated, and absent records all mean "not a failure", because this runs on a teardown path and must never interfere with it. tailFile reads forward keeping a ring rather than seeking from the end, and raises the scanner token limit to 1 MB. A workload emitting a 200 KB stack trace on one line is exactly the failure worth diagnosing, and the default 64 KB limit would error the scan out and lose the tail entirely. Gates confirmed to fail on revert: completionFailed never firing, and the default scanner limit losing the tail on a long line.
scttfrdmn
force-pushed
the
feat/736-console-log-tail
branch
from
October 8, 2026 19:25
d88a648 to
fcac400
Compare
scttfrdmn
added a commit
that referenced
this pull request
Oct 8, 2026
Promotes [Unreleased] to [0.126.0] and adds the compare link. MINOR, not PATCH, because this release contains a breaking change to a package other repos compile against: pkg/taskproto's three script generators now take a WrapperOptions struct and return an error (#765/#764). Pre-1.0 the project's rule is that a breaking change bumps MINOR. Also in this release: the cross-repo API surface gate that will report the next such change before it ships (#763/#679), `spawn logs` (#761), the spored console log tail it reads (#759), the MPI peer-SSH readiness poll (#758), and the remaining sleep-audit fixes plus the creation-stamp/orphan reaper work (#752, #755, #756, #757, #762). Release guard passed: both binaries report 0.126.0 for tag v0.126.0.
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.
Closes #736's diagnosis gap — option B, after a probe established it works.
The gap
When a
--commandworkload failed and the instance self-terminated,/var/log/spawn-command.logwent with it. The exit code survived in a tag; thereason did not. From outside, "the job failed" and "the job failed because
the package install 404'd" were the same event. A reporter hit exactly this: a
job failed, the instance self-terminated, and there was no way to find out why.
pkg/taskproto/flush.goalready solves this for the task path by uploadingthe log to the results prefix. A plain
spawn launch --command … --on-complete terminatehas no results bucket, so nothing flushed.Measured, not assumed
Three facts, all probed on real instances:
/dev/consoleappears inget-console-outputdescribe-instancesvisibilitystate = NoneThat third one matters enough to be in the user-facing log line. I made the
mistake myself: my first read was at ~3 minutes, returned 0 bytes, and I briefly
reported the whole approach as not working. An empty console is not "the write
failed", it is "nothing has been captured yet" — and an immediate read looks
exactly like a missing log.
A fourth fact, learned while validating the MPI work in #758: only some
cloud-init output reaches the console on its own. Rank 0's console held
mpirun's result but not the surrounding script'sechos. So this has to be anexplicit write — relying on a log line drifting to the console does not work.
Design choices
baseline boot consumes 13–17 KB, so copying a whole log would evict the
cloud-init messages that are also diagnostic — the ones that explain a
boot-time failure.
does not enlarge the un-reaped
spawn-results-*footprint on every launch,which was the standing objection to option A. The task path's S3 flush is
untouched.
space is shared with the boot messages.
checkCompletionwas already reading thecompletion record just to log it.
completionFailedis lenient by design — unparseable, truncated and absentrecords all mean "not a failure", because this runs on a teardown path and must
never interfere with it. All four cases are tested.
tailFilereads forward keeping a ring rather than seeking from the end, andraises the scanner's token limit to 1 MB. A workload emitting a 200 KB stack
trace on one line is exactly the failure worth diagnosing, and the default
64 KB limit would error the scan out and lose the tail entirely.
sysWriteConsolefollows the package's existing platform split(
sys_linux.go/sys_windows.go/sys_other.go, alongsidesysWarnUsers) andis a no-op on Windows and dev builds, where
/dev/consoledoes not exist.Cross-compiled for
windows/amd64andlinux/arm64to confirm.Verification
completionFailednever firescompletionFailed("{"status":"failed","exit_code":1}") = false, want true — the reported casethe tail lost its last line to a long-line scan error — which is the case most worth diagnosinggofmt,go vet ./...,go test -short ./..., cross-compile ×2,make check-docs, changelog gate,semgrep(0 findings).A process note
These six files were briefly committed onto #758's branch by mistake — they were
uncommitted when I switched branches and a
git add -Aswept them in. Split backout by extracting them from that commit, resetting this branch to
main, andrestoring them here. #758 is being corrected to contain only its own changes;
neither branch has been merged in the interim, so nothing downstream saw the mix.
Not in scope
The ~5-minute capture delay means the CLI should probably tell a user where to
look when a
--on-complete terminatejob fails, rather than relying on themknowing
get-console-outputexists. That is a separate UX change and wants itsown issue.