Skip to content

fix: spored install race (#27) + single-instance --check-complete (#26) - #28

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/status-check-complete-and-spored-race
May 31, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/status-check-complete-and-spored-race

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Two bugs blocking aws-microbiome-demo.

#27 — spored install "Text file busy"

The user-data bootstrap downloaded spored directly over /usr/local/bin/spored with curl -o. If a spored was already running (baked into the AMI or from a prior boot), the in-place write failed with ETXTBSY — and since the bootstrap runs under set -e, cloud-init marked the entire user-data (including the user's appended script) as failed.

  • Download to a temp file → verify checksum there → systemctl stop spored → atomic mv into place. rename(2) over a busy binary is allowed (the running process keeps the old, now-unlinked inode), so no ETXTBSY.
  • Run the custom user-data section under set +e so a non-fatal bootstrap warning no longer skips the user's script.

#26 — spawn status --check-complete always exited 0 for single instances

The standardized codes (0/1/2/3) were only wired for sweeps; the instance path just SSHed in, printed spored status, and returned nil → always exit 0.

  • Add --check-complete to spored's status subcommand: inspects the completion file and exits 0=complete, 1=failed (JSON status), 2=running (absent), 3=error. Decision logic factored into checkCompleteCode for unit testing.
  • spawn status --check-complete <instance> forwards the flag over SSH and propagates spored's exit code (SSH-level 255 → 3).

This makes the documented contract real; the docs PR (#347) currently warns it's sweep-only and can be updated once this ships.

Tests

checkCompleteCode covers absent/empty/success/failed/non-JSON. Build + vet green across spawn and spored.

)

#27 — spored install "Text file busy":
The user-data bootstrap downloaded spored directly over /usr/local/bin/spored
with `curl -o`. If a spored was already running (baked into the AMI or from a
prior boot) the write failed with ETXTBSY, and because the script runs under
`set -e`, cloud-init marked the entire user-data — including the user's appended
script — as failed.
  - Download to a temp file, verify the checksum there, then `systemctl stop
    spored` and atomically `mv` into place. rename(2) over a busy binary is
    permitted (the running process keeps the old inode), so no ETXTBSY.
  - Run the custom user-data section under `set +e` so a non-fatal bootstrap
    warning no longer skips the user's script.

#26 — `spawn status --check-complete` always exited 0 for single instances:
The standardized exit codes (0/1/2/3) were only implemented for sweeps; the
instance path SSHed in, printed `spored status`, and returned nil.
  - Add `--check-complete` to spored's `status` subcommand: inspects the
    completion file and exits 0=complete, 1=failed (JSON status), 2=running
    (absent), 3=error. Logic factored into checkCompleteCode for testing.
  - `spawn status --check-complete <instance>` now forwards the flag over SSH
    and propagates spored's exit code (mapping SSH's 255 to 3).

Tests: checkCompleteCode covers absent/empty/success/failed/non-JSON.
@codecov

codecov Bot commented May 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 15.38462% with 77 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/launch.go 0.00% 30 Missing ⚠️
cmd/spored/main.go 36.84% 23 Missing and 1 partial ⚠️
cmd/status.go 0.00% 23 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 35820cb into main May 31, 2026
1 of 2 checks passed
@scttfrdmn
scttfrdmn deleted the fix/status-check-complete-and-spored-race branch May 31, 2026 04:39
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