Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
BuildLinuxBootstrap appended the --plugin declarations after linuxBootstrapBody, which ends in `systemctl start spored`. The unit is Type=simple, so systemctl returns once spored is forked, and spored reads /etc/spawn/plugins.json exactly once at startup. Plugins loaded only if the bootstrap's cat won the race. The declarations are now written before the body, alongside /etc/spawn/command and the ready-gates list, so the file exists before spored is installed. TestPluginsJSONExistsWhenSporedStarts runs the real generated bootstrap under bash with every external command stubbed and records, from the systemctl stub, whether the file exists at `start spored`.
scttfrdmn
added a commit
that referenced
this pull request
Oct 17, 2026
…1023's plugin order (#1007) The sandboxed bootstrap tests execute the Linux user data under bash with stubbed spored and su, which the Windows CI job (#973) cannot reproduce, so they skip there as the other Linux-bootstrap execution tests do (#1002). Rebased onto #1023/#1045, plugins.json is written before spored starts, so the post-spored stop sits straight after the bootstrap body; the changelog and the ordering test's comment now say so. (#1007)
scttfrdmn
added a commit
that referenced
this pull request
Oct 17, 2026
…1023's plugin order (#1007) The sandboxed bootstrap tests execute the Linux user data under bash with stubbed spored and su, which the Windows CI job (#973) cannot reproduce, so they skip there as the other Linux-bootstrap execution tests do (#1002). Rebased onto #1023/#1045, plugins.json is written before spored starts, so the post-spored stop sits straight after the bootstrap body; the changelog and the ordering test's comment now say so. (#1007)
scttfrdmn
added a commit
that referenced
this pull request
Oct 17, 2026
…1021) * Stop a Spot replacement from re-running the user's workload (#1007) A replacement EC2 launches from a leaked persistent Spot request boots the original's user data. The bootstrap started --command in the background before spored, so the replacement re-ran the workload from the start, side effects included, while spored was deciding to retire it. New `spored is-spot-replacement` runs spotrequest.DetectReplacement and exits 0 (replacement), 1 (not) or 2 (unknown). It retries an inconclusive read every 5s for up to --timeout (60s), and not at all on an IAM refusal. The Linux bootstrap calls it twice through spawn_is_spot_replacement: inside the backgrounded --command subshell, ahead of the command, so it never delays spored's start; and right after spored starts, where a replacement exits the script. So storage, plugins, the container, custom user data and the MPI, batch-queue and pool-worker scripts appended later don't run either. Definite answers are cached in /run/spawn. Only exit 0 skips. Unknown, a missing spored, an older spored without the subcommand (cobra exits 1) and a timeout all run the workload, as before. Holding would strand originals whenever EC2/IMDS is slow or a custom role can't read tags; a replacement that gets past it is still retired by spored and alarmed by the reaper. The Windows bootstrap starts no workload (it runs no --command or user data), so it has nothing to gate; a comment says what to do if it gains one. Also adds TestRunDaemonStartsTheReplacementCheck, which fails if runDaemon stops starting the #995 check (the gap #1008 noted), and a Detection.Err field so the subcommand can tell an IAM refusal from a transient failure. The bootstrap tests run the generated --command block and the post-spored tail under bash with stubbed spored and su; each new test was watched failing against a compiling revert. (#1007) * Run the post-spored replacement stop after the plugin declarations (#1007) spored reads /etc/spawn/plugins.json once, at startup, and the bootstrap writes it just after `systemctl start spored`. Putting the stop's EC2 round trip between the two would have made spored miss the declarations on every original instance. The stop now follows the plugins block; a gate keeps it there. The existing race is filed as #1023. (#1007) * Name the original instance in spot_replacement_retired (#1007) The notification comes from the replacement, whose instance id nobody registered with spore-bot, so the bot's registration gate dropped every DM and SMS for it. spored now also sends original_instance_id (via Notifier.WithOriginalInstance), which spore-bot uses for this event alone. Older bots ignore the unknown field. (#1007) * Skip the bash-run Spot replacement bootstrap tests on Windows; note #1023's plugin order (#1007) The sandboxed bootstrap tests execute the Linux user data under bash with stubbed spored and su, which the Windows CI job (#973) cannot reproduce, so they skip there as the other Linux-bootstrap execution tests do (#1002). Rebased onto #1023/#1045, plugins.json is written before spored starts, so the post-spored stop sits straight after the bootstrap body; the changelog and the ordering test's comment now say so. (#1007) * Use the repo's bare nosemgrep on the spot-replacement test harness (#1007)
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 #1023
What
BuildLinuxBootstrapappended the--plugindeclarations (cat > /etc/spawn/plugins.json) afterlinuxBootstrapBody. The body ends insystemctl start spored. The unit isType=simple, sosystemctl startreturns as soon as spored is forked. spored reads the file once, at startup:provider.loadPluginDeclarations, thenagent.newAgent→rt.LoadFromDeclarations. So plugins loaded only if the bootstrap'scatwon a race against spored's IMDS reads and its firstDescribeTags.The declarations are now written before the body, next to
/etc/spawn/commandand the ready-gates list. The file exists before spored is even installed.Why this, and not watch/reload in spored. Moving the write removes the race by construction, and changes nothing in spored. Watch/reload would add a new runtime path (fsnotify or polling, partial-write handling, loading plugins after the agent is running) to fix an ordering bug in a script. A reload could also be wanted later for plugins changed at runtime, but this bug doesn't need it.
Test
pkg/launcher/bootstrap_plugins_order_test.go,TestPluginsJSONExistsWhenSporedStarts, is bash-level. It runs the real generated bootstrap:PATHis an empty directory, so every external command reaches bash'scommand_not_found_handle. That handler logs the command and succeeds, passesmkdir/cat/chmodthrough to the real binaries, and answersunamewithx86_64./etc/spawnis rewritten into a temp dir.The
systemctlstub records whetherplugins.jsonis non-empty at the moment it is asked tostart spored. The test also fails ifstart sporedis never reached, so a harness that stops early can't pass vacuously. Every harness anchor fails loudly if it disappears. The test skips on bash < 4 (macOS/bin/bash3.2 has nocommand_not_found_handle).Against the original ordering, it fails with
spored was started before /etc/spawn/plugins.json was written (recorded "absent"), andgo vetis clean. It passes with the fix.Checks
make check(credentials stripped): the only failure is the known Docker-onlyTestGenerateWrapper_ChownFixesCrossUIDStickyUnlink_Docker.make check-nested: 9 modules clean.golangci-lint --new-from-rev=origin/main ./pkg/launcher/...: 0 issues.Interaction with #1021
#1021 puts
script += spotReplacementStopScriptimmediately after the plugin block, and its comment explains that placement by this race.linuxBootstrapBody(this PR), and put the stop directly afterscript += linuxBootstrapBody.systemctl start spored.TestSpotReplacementStopComesAfterPluginDeclarationsstill passes, because the plugins now precede the whole body. It no longer protects anything, so it can stay as harmless or be removed.Not verified
This was not run on a real instance. The ordering is observed under a stubbed bash run, not under cloud-init and systemd.