Repository navigation
fix: --command as instance user, idempotent IAM, Tier 2 fixes (#61, #64) - #69
Merged
Merged
Conversation
…al' (#61) --command (and the parameter-sweep workflow command) ran via 'su - local', but no 'local' user exists — the bootstrap creates $LOCAL_USERNAME. So the command silently failed with 'user local does not exist'. Also: the command-exec block was nested inside the sweep-only SWEEP_ID gate, so a plain single 'spawn launch --command' never ran it at all. Hoisted it out to run for any instance with a spawn:command tag, and run it as $LOCAL_USERNAME. TestTier2_CommandExecution now PASSES. Test harness: launchSem capped at 1 (serialize launches) to avoid the concurrent IAM-role race (#64) until that's fixed; PreStop poll widened to 3m (spored monitor ticks ~1m). Remaining Tier 2 failures (pre-stop, iam-policy, name-resolution) tracked in #61/#63/#64.
…#61) #64 — concurrent launches raced on the shared spored-instance-role. CreateOrGetInstanceProfile / createIAMRole did check-then-act on a shared role+profile, so parallel launches failed with EntityAlreadyExists / LimitExceeded. Made the IAM setup idempotent: - retryIAM() treats already-exists as success and retries throttling with backoff; applied to CreateRole, CreateInstanceProfile, and AddRoleToInstanceProfile. - iamErrorCode/isAlreadyExists/isThrottle classify via smithy.APIError with a message fallback. NOTE: the modeled SDK codes drop the "Exception" suffix (EntityAlreadyExists, LimitExceeded) while substrate keeps it, so we match on the code prefix. - TestCreateOrGetInstanceProfile_Concurrent (8 goroutines, same role) + unit tests for the classifiers. e2e — with IAM setup now concurrency-safe, raise launchSem 1→4 so the launch burst is bounded but no longer serialized; running/assertion phases stay fully parallel. TestTier2_PreStop — rewritten to assert the real path: completion → grace → pre-stop → stop, then start back up and verify the marker. The marker is written to /var/tmp (NOT /tmp): the stop/start cycle reboots the instance and /tmp is wiped on boot (systemd-tmpfiles, AL2023), so a /tmp marker would false-negative even when pre-stop works. status — in --check-complete mode, resolveInstance / findSSHKey failures now exit 3 (error/unknown), not cobra's exit 1 (which means "task failed"). A just-launched instance is unresolvable for ~1s (InvalidInstanceID.NotFound); pollers must keep polling, not conclude failure (nf-spawn#31).
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.
Summary
Resolves the remaining #61 Tier 2 failures and the #64 IAM race uncovered while getting Tier 2 green. (The two spored lifecycle bugs found in the same investigation — #65/#66 — ship separately in #67.)
#61 —
--commandran as a nonexistent user / was gated to sweeps (already committed: 732e0f6)--commandwas nested inside the sweep-only branch and ransu - local(thelocaluser never exists). Hoisted it out so any instance with thespawn:commandtag runs it, assu - "$LOCAL_USERNAME".#64 — concurrent launches raced on the shared IAM role
CreateOrGetInstanceProfile/createIAMRoledid check-then-act on a sharedspored-instance-role+ profile, so parallel launches failed withEntityAlreadyExists/LimitExceeded. Made IAM setup idempotent:retryIAM()treats already-exists as success and retries throttling with backoff; applied toCreateRole,CreateInstanceProfile,AddRoleToInstanceProfile.iamErrorCode/isAlreadyExists/isThrottleclassify viasmithy.APIErrorwith a message fallback. Note: modeled SDK codes drop theExceptionsuffix (EntityAlreadyExists,LimitExceeded) while substrate keeps it → match on code prefix.TestCreateOrGetInstanceProfile_Concurrent(8 goroutines, same role) + classifier unit tests.e2e — unblock parallel launches
With IAM setup now concurrency-safe,
launchSem1→4: the launch burst is bounded but no longer serialized; running/assertion phases stay fully parallel.TestTier2_PreStop— assert the real pathRewritten to verify completion → grace → pre-stop → stop, then start back up and check the marker. The marker is written to
/var/tmp, not/tmp: the stop/start cycle reboots the instance and/tmpis wiped on boot (systemd-tmpfiles, AL2023), so a/tmpmarker would false-negative even when pre-stop works. (Caught during #66 validation.)status --check-complete— correct exit codesresolveInstance/findSSHKeyfailures now exit 3 (error/unknown), not cobra's exit 1 ("task failed"). A just-launched instance is unresolvable for ~1s (InvalidInstanceID.NotFound); pollers must keep polling. (nf-spawn#31.)Validation
IAM concurrency + classifier tests pass;
go vet -tags=e2e_tier2 ./test/e2e/clean. Full Tier 2 re-run is gated on the #65/#66 fix being released to the S3 binary bucket (instances pull spored from S3 at boot), since PreStop/on-complete depend on the now-fixed monitor.Related
Closes #64
Contributes to #61