Repository navigation
fix(mpi): strip inherited MPI cluster keys at boot (#1343) - #1363
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
scttfrdmn
force-pushed
the
fix/1343-legacy-peer-key
branch
from
October 27, 2026 04:40
11856fe to
cfdeec4
Compare
An instance launched from an image of an MPI cohort member authorized that cohort's cluster key for root. instancestate.StripClusterKeys now removes every line of /root/.ssh/authorized_keys whose last field is exactly spawn-mpi-cohort, once per instance (recorded in /var/lib/spawn/root-ak-owner, so a source whose bootstrap re-runs keeps its live cohort's key). It runs from the bootstrap body's existing spored discard-inherited-state call and at spored startup, so the user data gains no bytes. The MPI SSM key install records the instance too, so strip and install agree in either order. spawn ami create does not touch the source's keys. Pre-#1338 untagged rank-0 lines cannot be identified, and images record nothing that would let spawn find them (#1364); the CHANGELOG and create-ami help give the rebuild.
scttfrdmn
force-pushed
the
fix/1343-legacy-peer-key
branch
from
October 27, 2026 05:31
cfdeec4 to
ff09557
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.
An instance launched from an image of an MPI cohort member no longer authorizes that cohort's cluster key for root.
Fixes #1343
Reworked per owner decision: strip at boot instead of editing the live source. The first version of this PR held the keys out of the source across CreateImage. That version is gone: no hold/restore scripts, no rank-0 key read, no
Client.ImageSnapshotsTaken, no SSM wait, and no new IAM.api/public-surface.txtanddocs/reference/cli-iam-actions.mdmatch main.What changes
instancestate.StripClusterKeys(new,pkg/instancestate/clusterkeys.go) removes every line of/root/.ssh/authorized_keyswhose last field is exactlyspawn-mpi-cohort./var/lib/spawn/root-ak-owner(userdata.MPIClusterKeyStripOwnerFile) records the instance the strip ran for, and nothing is touched when it names this instance. So a source whose bootstrap runs again (cloud-init cleanand the CreateImage reboot), or whose spored restarts, keeps its live cohort's key. An instance launched from its image strips it./usr/local/bin/spored discard-inherited-state || true(ami create: per-instance spored/plugin state (plugins.json, job-array env, peer files) is still baked into images #1241), the published signed body (User data: fetch the bootstrap from S3 behind a small verifying stub, removing the 16 KiB ceiling (follow-up to #1246) #1274);provider.discardInheritedState), which also covers an image launched outside spawn.--mpi, the discard runs before the MPI script touches root'sauthorized_keys, and before enrollment, so the strip comes first. On an image with MPI preinstalled, enrollment can pass, and the SSM install run, before the bootstrap reaches the strip. SoinstallPubKeyCommandnow also writes the record for its instance, and a later strip leaves this cohort's key alone.spawn ami createdoes not touch the source's keys.Where the strip lives, and the size impact
I wrote a shell version in the body first. It added 184 gzipped bytes to the bare inline bootstrap, from 8023 to 8207, over the 8192-byte budget (
TestBareBootstrapFitsItsBudget). So the strip lives in spored instead, behind thediscard-inherited-statecall the body already makes. Its user-data and stub cost is 0 bytes:pkg/launcheris unchanged, the bare inline bootstrap stays 8023 gzipped and the release stub 1827. The SSM key-install command grows by about 60 bytes, and that is not user data. Windows is not affected: the Windows bootstrap never callsdiscard-inherited-state, the subcommand's strip is a no-op off Linux, and the daemon path is gated on Linux and root.Images made before this release
Releases before #1338 installed rank 0's key untagged (
root@ip-...), and nothing on an instance tells that line from a user's key. Nor can spawn find such images. An image records onlyspawn:managed,spawn:created,spawn:created-from,spawn:source-region,spawn:arch,spawn:gpu,spawn:base-amiand the user's--tags, not the source's MPI tags orspawn:version. #1364 tracks recording those, so a later fix can warn. The rebuild is documented in the CHANGELOG, thecreate-amihelp and spore-host/spore-host#614.Gates (each watched failing against a compiling revert)
TestStripClusterKeysRemovesTaggedLinesAndKeepsEveryOtherByte(Go, temp root). The fixture holds:from=options;spawn-mpi-cohort-notes;spawn-mpi-cohortmid-comment;#comment and a blank line;Reverts:
-noteskey is dropped;TestStripClusterKeysOncePerInstance: reverting the owner check fails it.TestEveryLinuxLaunchStripsInheritedClusterKeys(cmd) covers a plain launch, the published body, and--mpiranks 0 and 1, where the discard must come before the MPI script's first/root/.ssh/authorized_keys. Replacing the discard line in the body fails it.TestDiscardInheritedStateStripsInheritedClusterKeys(cmd/spored) andTestDiscardInheritedStateReconcilesThisInstance(pkg/provider) check that both call sites strip for this instance. Dropping either call fails its test.TestBootStripAndKeyInstallAgreeInEitherOrder(pkg/mpicohort; the install runs under bash, the strip in Go) runs strip then install, install then strip, and strip, install, strip. Each must end with the user's key plus this cohort's key, not the parent's. Reverts:install, stripfails;TestAMICreate_NeverTouchesAuthorizedKeys(negative) covers plain, MPI rank 0 and MPI non-zero sources. Only the run-state clean and CreateImage run, and no script mentions/root/.ssh. Making the clean also touchauthorized_keysfor MPI sources fails it.The strip itself is Go, so dash and busybox don't apply to it. The changed shell (the key install) was run under Debian dash and Alpine busybox (docker, local images) with the expected result.
Checks
make checkOK,make lint0 issues in all 10 modules,semgrep scan --config=auto --error .0 findings,make check-docsclean,make api-snapshotandmake cli-iam-actionsgive no diff against main. Not tested on AWS.