Skip to content

status --check-complete exits 3 (not 1) when the bootstrap failed before creating the login user: SSH auth fails and there is no SSM fallback #1493

Closed

Description

@scttfrdmn

Found while live-testing #1488 (#1484) with a CLI built from fix/1484-bootstrap-failclosed at a45d30e, in us-east-1, on t4g.small with AL2023.

What happens

When the bootstrap fails before the login user exists, spawn status <id> --check-complete exits 3 (error). It should exit 1 (failed). spored has the failed record and says so.

Repro: USER=wheel spawn launch fc2 --command 'echo SHOULD_NOT_RUN' --ttl 15m --no-dns --yes. Here useradd -m wheel fails with status 9 because wheel is a group, not a user. The #1484 record is written correctly, and the instance stays running because no --on-complete was given.

$ spawn status i-0cfc74096c1099179 --region us-east-1 --check-complete
Looking up instance i-0cfc74096c1099179 in us-east-1...
ssh: [email protected]: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
$ echo $?
3

The same check run on the instance over SSM:

# cat /tmp/SPAWN_COMPLETE
{"status": "failed", "exit_code": 9, "source": "bootstrap"}
# /usr/local/bin/spored status --check-complete; echo rc=$?
rc=1

Why (cmd/status.go, cmd/utils.go)

  • resolveSSHUser uses the spawn:local-username tag, which is wheel here. That user was never created, so /home holds only ec2-user. The EC2 key pair is still installed for ec2-user.
  • runStatus falls back to runStatusOverSSM only when no local key resolves or there is no public IP. An SSH auth failure (exit 255) is mapped to exit 3, and SSM is not tried.

Impact

This is narrow: it affects only a bootstrap that fails before the user and key setup. useradd is the first step in the #1484 window, so that covers any failure at that step. A caller polling --check-complete without --on-complete, which is the documented way to keep a failed instance, sees "error/unknown" until the TTL ends the instance. It never sees "failed". With --on-complete set, the instance ends anyway (verified), so the only cost is the misleading status. This was not a regression from #1488: before it, no record existed at all.

Possible fix

When the SSH path exits 255 in --check-complete (or any status) mode, retry over SSM (runStatusOverSSM) before reporting 3.

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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions