Repository navigation
feat(plugin): reach spored's push API over SSM on keyless instances (#855) - #1243
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…855) Plugin install/list/status/remove go through a pushTransport. An instance without a public IP is reached by running curl to the loopback push API on the instance over SSM SendCommand (token read on the box, body staged in chunks); one with a public IP tries SSH first and falls back to SSM only when SSH could not reach the API, so an answered install is never repeated.
scttfrdmn
force-pushed
the
fix/plugin-ssm-855
branch
from
October 20, 2026 18:01
a28856c to
f994c35
Compare
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 #855
Decision taken (option 1 of the issue, the owner default)
Run the push-API request on the instance over
ssm:SendCommand(curlto127.0.0.1:7777, with the token read on the box). This reuses theRunShellScriptmachineryspawn extenduses (#1113). There is no Parameter Store polling and no new spored code.What changes
cmd/plugin_push.goadds apushTransportinterface.install, its preflight and status poll,list,statusandremoveall go through it, so the payload code is the same on every path (pluginInstallPayload). The implementations:sshPush: the existing SSH token read and port-forward.ssmPush: renders POSIX-sh scripts. The body is base64 in a root-only (umask 077)/run/spawn-push-<nonce>file, staged across several SendCommands when it exceeds 16 KiB of base64. SSM documents are capped at 64 KB and the per-parameter limit is undocumented, so the chunk size is deliberately conservative.printfbuiltin, so it never appears in a command line. curl runs with--noproxy '*'.SPAWN_PUSH_STATUS <code> <bytes>and then the body, so a response cut short by SSM's 24,000-character stdout limit is reported as truncated rather than parsed. Staging files are removed.fallbackPush: tries SSH first and switches to SSM for this call and every later one, but only onerrPushUnreachable, meaning the API was never reached (token read failed, the tunnel failed to start, or the dial failed). An SSH answer, even an HTTP error, is returned unchanged, so an install is never sent twice. If both fail, the error names both and the command exits non-zero.resolvePluginSSHHostis removed. Its "instance has no public IP to SSH to" error was the failure this issue describes.spawn plugin installupdated; gen-docs regenerated.Gates, each watched failing against a revert that compiles
TestPluginInstallOnAKeylessInstanceGoesOverSSMWithTheSamePayload(small and chunked bodies). It runs the recorded SSM scripts for real undersh, with the instance's paths rewritten into a temp dir and the loopback URL pointed at a recording httptest spored. It asserts:Reverting the keyless case to SSH made it fail ("transport SSH, want SSM"). Dropping the staging chunks made it fail ("payload over SSM differs ... 694 vs 49846 bytes").
TestPluginPushFallsBackToSSMOnlyWhenSSHCannotReachTheAPIcovers three cases: unreachable SSH falls back and stays on SSM; an answered SSH install is not retried; if both fail, the error names both. Disabling the fallback made it fail.TestChoosePushTransportfailed when I reverted the no-public-IP case.TestPluginPushOverSSMReportsTheAnswerandTestParseSSMPushOutputRefusesATruncatedAnswercover status, 412 preflight, truncation and the case where there was no HTTP answer.Checks
check-build-tags, which fails identically on unmodified main on this machine.nosemgreps: the sandboxexec.Command, the same pattern asbootstrap_spot_replacement_test.go, and an httptest handler write).Not verified
base64 -dand curl on AL2023/Ubuntu/Rocky, and spored answering.ensureHostIdentity(for a plugin's local SSH-based steps such as mutagen) still assumes SSH. A plugin whose local steps SSH to the instance still needs SSH. That is the plugin's own requirement, not the push API's.