Repository navigation
fix: --command honours a custom --completion-file; queue files may omit queue_id (#1131) - #1164
Merged
Merged
Conversation
…it queue_id (#1131) The --command wrapper wrote its completion record to a hardcoded /tmp/SPAWN_COMPLETE while spored watched --completion-file, so a custom path never fired --on-complete. Render the configured path, shell-quoted, into both write sites. queue.LoadConfig rejected an empty queue_id before the CLI's generate-if- missing branch could run. Add LoadUserConfig, which generates the ID before validating, for --batch-queue files; LoadConfig stays strict for the runner. Fixes #1131
scttfrdmn
force-pushed
the
fix/1131-completion-file
branch
from
October 19, 2026 04:56
d31af7f to
2fda43b
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Summary
Two bugs from #1131.
1.
--commandignored--completion-file, so--on-completenever fired (cost leak).spored watches the path in
--completion-file(LaunchConfig.CompletionFile). The--commandwrapper inpkg/launcher/bootstrap.gowrote both of its completion records to a hardcoded/tmp/SPAWN_COMPLETE. That covers the failed-prerequisite write and the normal exit write. With a custom path, spored never saw completion and the instance billed until its TTL.BootstrapConfig.CompletionFileis new.BuildLinuxBootstraprenders it into both write sites withsecurity.ShellQuote. The default is still/tmp/SPAWN_COMPLETE.mkdir -p "$(dirname -- <path>)" || truebefore each write. Without it, a custom path in a directory that doesn't exist yet would fail the write underset -e, and the same leak would come back.buildUserData) and the headlesslauncher.Provisionboth passconfig.CompletionFile./tmp/SPAWN_EXITCODEis unchanged. It isn't tied to the completion path, and spored doesn't watch it.2.
--batch-queuefiles had to setqueue_id.cmd/launch_batchqueue.gogenerated an ID "if not set". Butqueue.LoadConfighad already runValidateQueue, which rejects an emptyqueue_id, so that branch never ran.queue.LoadUserConfiggenerates the ID before validating.--batch-queuenow uses it, and the dead branch is removed.queue.LoadConfigstays strict on purpose. The on-instance runner reads the copy the CLI uploaded, which always has an ID. If the runner invented a different ID, it would diverge from the one the CLI used for S3 paths and tags.Docs follow-up needed (spore-host repo, not changed here). The example in
docs/guides/batch-queue.mdalready omitsqueue_id, so before this fix the documented example failed to load. Its field table has noqueue_idrow. Add one:queue_id: no, generated asqueue-<timestamp>if omitted.Gates (each watched failing against a revert that compiles)
pkg/launcher/bootstrap_completion_file_test.gocat > <target> <<JSONEOFwrite by regex (fails if it finds none).'<custom path>', never the default.'/tmp/SPAWN_COMPLETE'.<tmp>/new dir/it's $HOME done. It runsbash -non the whole script, then runs the renderedmkdirandcatunder bash and checks the record lands at exactly that path./tmp/SPAWN_COMPLETE;ShellQuotedropped; builder ignorescfg. All fail.cmd/launch_completion_file_test.go:buildUserDatawithCompletionFile: /data/donemust emitcat > '/data/done' <<JSONEOF. Revert tried: CLI passes"". It fails, while the pkg tests pass.pkg/queue/queue_optional_id_test.go:LoadUserConfiggenerates aqueue-…ID and keeps an explicit one;LoadConfigstill rejects a missing ID. Revert tried:if false && …. It fails.cmd/launch_batchqueue_id_test.go:launchWithBatchQueuewith an ID-less file stops at the--instance-typecheck, which comes after loading and before any AWS call. Revert tried: back toqueue.LoadConfig. It fails withqueue_id is required.Not covered
launcher.ProvisionpassingCompletionFilehas no unit test. That path makes AWS calls before it builds the bootstrap.--mpi-command(pkg/userdata/mpi.go) also hardcodes/tmp/SPAWN_COMPLETE, including the ssh writes to peers. It's a separate generator, so it's filed separately: Refs --mpi-command ignores a custom --completion-file, so --on-complete never fires (sibling of #1131) #1170.Checks
make check: fmt, vet (all GOOS), hermetic short tests, nested and tidy all pass.GOOS=linux staticcheck ./...is clean. On darwin, SA4023 inpkg/agent/sys_other.gois known noise.check-build-tagsfails with identical output on unmodifiedorigin/mainon this machine, so it's local-only.api/public-surface.txtis regenerated (+BootstrapConfig.CompletionFile), with a CHANGELOG### Addedentry.semgrep scan --config=auto --error .is clean.Fixes #1131