Skip to content

spawn status --check-complete returns exit 0 when /tmp/SPAWN_COMPLETE does not exist #26

Closed

Description

@scttfrdmn

Summary

spawn status <instance-id> --check-complete returns exit code 0 (complete) even when /tmp/SPAWN_COMPLETE does not exist on the instance and the workload is still running.

Steps to reproduce

  1. Launch an instance with a long-running user-data script that touches /tmp/SPAWN_COMPLETE at the end
  2. Immediately after SSH is ready (before the script finishes), run:
    spawn status <instance-id> --check-complete
    echo $?   # prints 0 — but the file doesn't exist yet
  3. SSH to the instance and confirm: ls /tmp/SPAWN_COMPLETE → No such file

Expected exit codes

Per the documented contract:

  • 0 = complete (/tmp/SPAWN_COMPLETE found)
  • 1 = failed
  • 2 = still running (file not yet present)
  • 3 = error

When the file doesn't exist and the instance is running, exit code should be 2, not 0.

Observed

Exit 0 returned immediately after instance boot, before the user-data script has had any chance to create the file. Instance CPU was at 100% (script actively running).

Impact

Callers that poll --check-complete to wait for a workload to finish will incorrectly conclude the workload is done, proceed to collect results, and find nothing. This is the blocking issue for https://github.com/scttfrdmn/aws-microbiome-demo.

Environment

  • spawn 0.36.5
  • Instance: t4g.small, us-east-1, running, CPU 100%
  • /tmp/SPAWN_COMPLETE confirmed absent via SSH

Activity

  1. added
    bug
    on May 31, 2026
  2. scttfrdmn commented on May 31, 2026

    @scttfrdmn
    ContributorAuthor

    Root cause confirmed

    --check-complete with its standardized exit codes (0/1/2/3) is only implemented for the sweep path (runSweepStatus in cmd/status.go), never for single instances.

    In runStatus, the instance path (cmd/status.go:77-95) just SSHes in, runs sudo /usr/local/bin/spored status, prints the output, and return nil — so the process exits 0 whenever SSH succeeds, regardless of whether /tmp/SPAWN_COMPLETE exists. The statusCheckComplete flag is read at line 49 only to forward to runSweepStatus; the instance branch ignores it entirely.

    Fix sketch

    The instance branch needs to honor --check-complete and map to the documented codes:

    • 0 complete — /tmp/SPAWN_COMPLETE (or the configured --completion-file) present
    • 1 failed — a failure marker present, or spored reports failure
    • 2 running — file absent, instance running
    • 3 error — SSH/instance unreachable, or instance not running

    spored already knows the completion file (completion-file config key, default /tmp/SPAWN_COMPLETE). Cleanest approach: add a spored status --check-complete mode that exits with these codes based on the file, and have spawn status --check-complete <instance> propagate spored's exit code (instead of always returning nil). Must use the instance's configured completion-file, not a hardcoded path.

    Note

    This is independent of the launch-time default — even an instance launched without --on-complete should report 2 (running) not 0 while the file is absent.

  3. added a commit that references this issue on May 31, 2026
  4. scttfrdmn commented on May 31, 2026

    @scttfrdmn
    ContributorAuthor

    Fixed in #28 (merged to main): spawn status --check-complete now forwards to spored's new --check-complete mode and propagates exit codes 0/1/2/3 for single instances. Ships in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions