Repository navigation
fix(status): --check-complete falls back to SSM when SSH cannot reach spored (#1493) - #1499
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 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.
Fixes #1493
What
spawn status <id> --check-completeexited 3 (error) when SSH to the instance failed: ssh's own exit status 255 was mapped straight to 3. When the bootstrap fails atuseradd, thespawn:local-usernameuser does not exist, so SSH is refused while spored has the failed record and exits 1. Now, when SSH cannot reach spored (ssh exits 255, or ssh cannot be started), spawn asks spored over SSM RunCommand. It uses the sameRunShellScriptcall that keylessspawn statusandspawn connect --no-public-ipalready make, then exits with spored's code. If SSM fails too, the exit is still 3.Design
checkCompleteViaSSH(ctx, runSSH, run ssmShellRunner, instance, stderr) intruns SSH first. Any status other than 255 is the remote command's answer and is returned as is, with no SSM call, so a normal poll costs the same as before. On 255 or a start failure, it prints ssh's diagnostic and a note to stderr, then callscheckCompleteOverSSM.checkCompleteOverSSMis now shared by the new fallback and the existing keylessrunStatusOverSSM --check-completepath. It maps the SSM result withcheckCompleteCodeFromSSM: spored's 0/1/2/3 pass through, and anything else is 3. A TimedOut or Cancelled invocation reports -1 and a missing spored reports 127; these used to reachos.Exitunchanged. The documented contract is still0=complete, 1=failed, 2=running, 3=error, from the flag help and docs-gen/status.md.ssmShellRunnertype (cmd/terminate_flush.go) and arunSSHfunc that wrapssshCmd.Run()throughsshExitStatus.spawn statusalready listsssm:SendCommandandssm:GetCommandInvocation(docs/reference/cli-iam-actions.md). I ranmake cli-iam-actionsand it produced no diff.--check-complete) status path does not change.Gate (cmd/status_check_complete_test.go)
Permission deniedtext and SSM returns ResponseCode 1. The test expects exit 1, exactly one SendCommand to the right region and instance carrying spored's--check-complete, and ssh's diagnostic kept on stderr.sshExitStatusis checked against a real 255 exit from a child process (this test binary).runStatuscallscheckCompleteViaSSHandrunStatusOverSSMcallscheckCompleteOverSSM.Each revert below compiled (
go vetwas clean), and the gate failed against it:return checkCompleteError: 3 tests fail, e.g.exit code = 3, want 1 (failed)andSSM RunCommand sent 0 times, want exactly 1.runStatusrestored to the inlinecode == 255 → os.Exit(3)mapping:runStatus does not call checkCompleteViaSSH.exit code = -1, want 3andexit code = 127, want 3.Checks
make check,make lint(0 issues in all 10 modules),semgrep scan --config=auto --error .andmake cli-iam-actions(no diff) all pass. No help text changed. User data and the published bootstrap body do not change.Not live-verified. No AWS calls were made; this needs a repeat of the issue's
USER=wheelrepro.