Repository navigation
fix(bootstrap): record a failed completion when the bootstrap fails after spored starts (#1484) - #1488
Merged
Conversation
Contributor
Author
|
Live-verified on EC2 (2026-11-02) with a CLI built from
Cost was under $0.01, and the leak check is clean (the agent's and mine). Follow-up: #1493, where |
Merged
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.
Fixes #1484
spawn bootstrap-bodysha256:f04b5d9a0a06f39801204a7f0357c5c94a6b8b16298fb2452bc3e1d31edfcc17(main at 54f9a61) →b447ce0938c5fafd7acc827e0f956bc884ff207e72f0dd0bea7d46c31d56fcbb(24279 → 24421 bytes raw). Deploy the sweep orchestrator from the release that carries this (it embeds the body; deploy checklist). The per-launch prefix changes too (one line inspawn_exit_guard).To stay inside the #1422 margin without raising the budget, three heredoc comment lines (data, so shellmin cannot strip them) are no longer written into
/etc/profile.d/session-timeout.sh,job-array.shandspawn-params.sh; their rationale moved to a shell comment. The variables those files set are unchanged.The gap
After
SPAWN_SPORED_UP=1,spawn_exit_guardreturned 0 on any exit. The body then runs ~330 lines underset -e(user, key, sudoers, session timeout, array/hostname/sweep setup, MOTD) before launching--commandor handing over to the user data after it. A failure there wrote no completion record:--on-completenever fired and the instance billed to its TTL/idle timeout.Design (mirrors #1485's
mpi-bootstraptrap)[ "$rc" = 0 ] || [ -n "$SPAWN_HANDED_OFF" ] || spawn_boot_failed "$rc"; return 0. It still never retires the instance after spored is up (spored enforces the TTL), and still ignores subshells (BASHPID check first).spawn_boot_failedlives in the body (so release launches don't carry it in user data), defined just beforeSPAWN_SPORED_UP=1, withSPAWN_HANDED_OFF=reset there. It writes{"status": "failed", "exit_code": <rc>, "source": "bootstrap"}to$SPAWN_CMD_COMPLETION_FILE(mkdir for a custom--completion-file), and logsspawn: bootstrap failed (status N, at line L: <cmd>) after spored started; recording it (#1484)to stderr and/var/log/spawn-command.log(which spored copies to the console on a failed record).SPAWN_HANDED_OFF=1: right after( ... ) &launches--command(the subshell then owns the outcome: success, failure, or a failed gate), and as the body's last statement (storage, container, custom user data, MPI, task runner own theirs). This replaces the issue's "command requested" test: the guard needs no knowledge of whether a command was requested (embedded or tag-delivered sweep command), so tag-delivered sweep commands are covered with no extra describe-tags.Decisions
--on-complete: current spored semantics are that the completion file is acted on only whenOnComplete != ""(agent.gostep 1;refreshForEarlyCompletionre-reads tags up to 5 times in case the tag was just not visible yet). I kept that: the record is written, spored does nothing, the TTL or idle timeout (spawn applies a 1h idle default when neither is set) ends the instance, andspawn status --check-completereports the failure. That is exactly what a failed--commanddoes today, and the command path documents omitting--on-completeas the way to keep a failed instance. Not a spored behaviour change. Escalating to retire-on-failure when no--on-completeis set would contradict that design for this one source; if the owner wants that, it belongs in spored (asource-aware default), as a separate decision.--command(interactive, or workload via--user-data/container/MPI/task runner): same failed record, same on-complete semantics, no retire.fatalRetireFuncretires only when nothing enforces the TTL; here spored does. The record matters because none of the user data after the body runs once it fails; with--on-completeset (as a user-data or pool workload would), the instance now ends instead of idling.--on-complete. Healthy boots write nothing new. CHANGELOG: Fixed (the record) and Changed (the body).MPI composition (#1485)
bootstraprecord.spawn_mpi_exitwrites itsmpi-bootstraprecord, then callsspawn_exit_guard, which seesSPAWN_HANDED_OFF=1and writes nothing. No terminate from either (spored up). One record.--mpi-command, a rank-0 bootstrap failure before the MPI script writes only rank 0's record; peers wait for one (bounded by TTL/idle), as when rank 0 dies outright.Gates (
pkg/launcher/bootstrap_failclosed_test.go, full inline bootstrap in the boot sandbox,fullBootgained abootOptsfor stand-ins and appended user data)TestBootstrapFailureAfterSporedWritesAFailedRecord: useradd (9), chown (5),chmod +x spawn-command.sh(6) with--command; useradd (9) and the MOTD chmod (7) without. Each: spored started, script exit = step status, record failed//bootstrap, log names the line, not retired, workload and user data did not run.TestBootstrapFailureAfterTheCommandLaunchedLeavesItsRecord: the MOTD step (after launch) waits for the command's record, then fails: the record stayscommand/3, no A bootstrap failure after spored starts but before --command launches writes no completion record; the instance bills to TTL #1484 line.TestBootstrapHandsOffAtTheCommandAndAtItsEnd: exactly twoSPAWN_HANDED_OFF=1, immediately after) &and as the body's last statement.TestNoRecordAfterTheBodyHandsOff: healthy boot writes nothing; custom user data ending infalsewrites nothing; MPI install failure (appended realGenerateMPIUserData) gives exactly onempi-bootstrap/137 record; bootstrap failure before the MPI script gives exactly onebootstrap/9 record and no MPI step.Watched failing against compiling reverts:
[ "$SPAWN_SPORED_UP" = 1 ] && return 0: all 5 window cases + "bootstrap fails before the MPI script" fail.) &: the after-launch test (bootstrap record overwrites the command's) and the structure test fail.bootstrap, record) and the structure test fail.AL2: the guard +
spawn_boot_failedrun underamazonlinux:2bash 4.2.46 (exit 9 → record + log line), andbash -nof the whole published body passes there.Live EC2 check (branch-built CLI, before merge)
A dev build inlines the body, so the branch CLI carries this change with no published body. Force a failure in the window by making
useraddfail: the bootstrap user name is$USER, normalised, soUSER=wheel(an existing group, not a user) should makeuseradd -m wheelfail with status 9 ("group wheel exists").USER=wheel spawn launch --command 'echo SHOULD_NOT_RUN' --on-complete terminate --ttl 30m ...(AL2023). Expect: the instance terminates within a few minutes (spored's on-complete, not the TTL); before it does,/tmp/SPAWN_COMPLETE={"status": "failed", "exit_code": 9, "source": "bootstrap"};/var/log/spawn-command.logand the console showspawn: bootstrap failed (status 9, at line N: useradd ...) after spored started; recording it (#1484); noSHOULD_NOT_RUNanywhere; spored journal shows "Completion signal detected" and the failed metadata; CloudTrail shows the terminate coming from the instance role via spored (notspawn_fatal_retire: no "FATAL" line).--on-complete(--ttl 15m): the record is written, the instance keeps running,spawn status --check-completereports failed, and the TTL ends it.$USER,--command 'exit 3' --on-complete terminate: record issource: command,exit_code: 3, no A bootstrap failure after spored starts but before --command launches writes no completion record; the instance bills to TTL #1484 line (the hand-off works on EC2).USER=wheelwith--mpi --count 2 --on-complete terminate: each member writes onebootstraprecord and terminates; noMPI setup failedlines.Afterwards verify no instance from these launches is left running.