Skip to content

feat(launch): --bootstrap-egress proxy on detached parameter sweeps; orchestrator ensures the proxy (#1515 PR B) - #1533

Merged
scttfrdmn merged 7 commits into
mainfrom
feat/1515-sweep-detached-proxy
Nov 5, 2026
Merged

scttfrdmn merged 7 commits into
mainfrom
feat/1515-sweep-detached-proxy

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Refs #1515

Sweep support, part B: --bootstrap-egress proxy on detached parameter sweeps. When a proxy has gone, the sweep orchestrator creates a new one, following the 2026-11-05 owner decision.

Submit (CLI)

  • Refusal removed. The detached refusal is gone: refuseDetachedSweepEgressProxy and its 3 call sites are deleted, and validateBootstrapEgressFlags loses its detachedSweep argument. detachedSettingsGuard now refuses only a config that names its own EgressProxyAddr.
  • Before the prompt. seedDetachedBootstrap runs each member's subnet check, as it did before. privateNetOf now returns the PrivateCheck. A member whose check relies on the proxy gets three things:
    • it is rendered with deploy.PendingAddr, which is 192.0.2.1:3128 (TEST-NET-1);
    • it is marked with spawn_egress_proxy_vpc, a new reserved key that is in detachedParamKeys;
    • it is collected by (region, VPC).
  • After the prompt and ensureDetachedInstanceProfile. ensureDetachedEgressProxies runs for each (region, VPC):
    • it calls findOrCreateEgressProxy, the foreground path, which also sets up spored-instance-profile;
    • it binds each member by rebinding the user data from PendingAddr to the proxy's address and adding the clients group through MemberGroups, after CheckMemberEgress;
    • it returns a SweepTarget for the record.
    • On failure: nothing is uploaded, and the proxies this submit created are terminated.
    • Placeholder guard: the uploaded params never carry the placeholder, and normalizeDetachedUserData fails closed if one is still there.
  • Schedules still can't use the proxy. A proxy member with no egress collector is refused, though no schedule sets --no-public-ip anyway.

Record

SweepRecord.EgressProxies []sweepproxy.Target (egress_proxies) is in a new stdlib-only package, pkg/egressproxy/sweepproxy, so scheduler-handler does not link the proxy's launch code. Putting it in deploy added 97 go.mod lines to that Lambda. Each target holds:

  • region, VPC, first AZ, public subnets, idle, version (the CLI's), profile, AMI, proxy user data (rendered by the CLI), and base tags (no launch time);
  • the rendered address and clients group;
  • the current phase, proxy, groups, CreatingSince, Created, errors and FailReason.

Orchestrator ensure phase (deploy.EnsureSweep, lambda/sweep-orchestrator/egress_proxy.go)

WaitReady is split into CheckReady (one look) and the loop. FindOrCreate and EnsureSweep share EnsureGroups, Find/Evaluate, Create/RunInput and CheckReady. No logic is duplicated.

  • failed: the members are failed with FailReason. No AWS calls.
  • creating: one CheckReady.
    • Ready: the target becomes ready and its members launch.
    • Terminal, or not ready 6 minutes (ReadyTimeout) after CreatingSince: the proxy is terminated, the target is failed, and the reason is recorded.
    • Otherwise: hold.
  • ready, or unset:
    • EnsureGroups re-creates deleted groups and reconciles their rules.
    • Find evaluates proxies against the recorded version.
    • If the recorded proxy is still reusable, it is used with no probe.
    • Otherwise another reusable proxy is used if one CheckReady passes.
    • Otherwise Create launches a new proxy from the recorded inputs, the target becomes creating, and its members are held.
  • Errors: a run of AWS errors holds the members for up to 6 minutes. An authorization error fails them at once.
  • The gate:
    • It runs once per target per launch batch, on both the single-region and multi-region paths.
    • hold: the batch stops at that member, and the queue is ordered. On a multi-region sweep only that region stops.
    • fail: the member is recorded failed with the reason, and the batch continues.
    • launch: if the current binding differs from the rendered one, the member's user data is rebound (RebindUserData) and so are its groups (RebindGroups), and its egress to the new proxy IP is checked.
  • Never blocks. No sleeps. Each poll's look is bounded by one probe of at most 60s, plus Create's existing instance-profile retry.
  • Cancel terminates only proxies that this orchestrator created and that are still creating. It is idempotent: live instances only.

IAM: SpawnSweepCrossAccountRole (scripts/setup-sweep-cross-account-role.sh)

  • Unchanged:
    • Role trust and creation: the script still creates the role only when an operator runs it.
    • Existing grants: the six statements below are added alongside them. RunInstances, CreateTags, TerminateInstances and the Describes were already granted unconditioned, and the PassRole of spored-instance-role already existed.
  • Golden test: TestSweepCrossAccountRoleGrantsTheEgressProxy holds the six new statements exactly. It also checks that no Resource uses a policy variable (Every spawn launch fails on v0.129.0/v0.130.0: spored role policy rejected (MalformedPolicyDocument) #1069) and that every condition key belongs to its action's service.
  • Coverage gate: TestEveryPrincipalCallIsGranted now claims ssm for the member-account context. Without the new statements it fails on the orchestrator's ssm:SendCommand/GetCommandInvocation and the SG actions.
  • SpawnSweepOrchestratorRole: nothing new.

Deploy checklist

  • lambda/sweep-orchestrator: code-only.
  • lambda/scheduler-handler: code-only, because it compiles pkg/sweep's record. Its behaviour doesn't change.
  • scripts/setup-sweep-cross-account-role.sh: manual. Re-run it per member account, after a real PutRolePolicy check on a throwaway role in spore-host-dev. Until then, a re-creation is denied and that VPC's members fail with the reason. Sweeps whose CLI-made proxy stays reusable are unaffected.

Checks

  • make check passes.
  • Hermetic go test ./... passes, run with the AWS env stripped. That covers root, lambda/sweep-orchestrator, scripts and all nested modules (all tidy).
  • e2e tier0 passes.
  • semgrep --config=auto --error is clean.
  • gen-docs, api-snapshot and cli-iam-actions were run. docs-gen/launch.md was regenerated for the new --bootstrap-egress help.
  • Revert-gated: each of the following was broken on purpose and its test failed:
    • holding;
    • rebinding;
    • failure handling;
    • cancel scoping;
    • terminate on timeout;
    • the 6-minute budget;
    • re-create;
    • the detached refusal;
    • CLI binding;
    • the SSM grant (golden and coverage).

No AWS was touched.

@scttfrdmn

Copy link
Copy Markdown
Contributor Author

Cross-account policy: real PutRolePolicy + simulation (spore-host-dev 435415984226, throwaway role)

I rendered the policy from scripts/setup-sweep-cross-account-role.sh at 35edf4af, substituting CURRENT_ACCOUNT_ID=435415984226. It has 11 statements, is 2493 bytes, and contains no ${…} policy variables.

I put it on a throwaway role, zz-sweep-xacct-check-1533, whose trust is the EC2 service only: no cross-account trust.

  • PutRolePolicy: ACCEPTED.
  • Simulation:
Action Context Decision
ec2:CreateSecurityGroup (security-group) aws:RequestTag/spawn:managed=true allowed
ec2:CreateSecurityGroup (security-group) no request tag implicitDeny
ec2:AuthorizeSecurityGroupIngress ec2:ResourceTag/spawn:managed true / false allowed / implicitDeny
ec2:RevokeSecurityGroupEgress managed true / false allowed / implicitDeny
ssm:SendCommand (instance) managed + spawn:egress-proxy=vpc-* allowed
ssm:SendCommand (instance) managed, not a proxy implicitDeny
ssm:SendCommand (instance) untagged implicitDeny
ssm:SendCommand (document) AWS-RunShellScript / AWS-RunPowerShellScript allowed / implicitDeny
  • Cleanup: the throwaway role is deleted and confirmed gone.

Owner decision (2026-11-05): release, then test. This merges into v0.160.0. After the CI deploy, the live plan runs in spore-host-dev:

  1. Update SpawnSweepCrossAccountRole (snapshot first, diff after).
  2. Run a plain non-proxy detached sweep, as the regression check.
  3. Run the proxy plan: normal, forced re-create, timeout, cancel.

If anything regresses, roll back by dispatching the v0.159.0 deploy.

@codecov

codecov Bot commented Nov 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.42424% with 58 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/launch_sweep_detached_egress_proxy.go 77.57% 24 Missing ⚠️
pkg/egressproxy/deploy/sweep.go 89.87% 16 Missing ⚠️
pkg/egressproxy/sweepproxy/sweepproxy.go 0.00% 8 Missing ⚠️
cmd/launch_sweep.go 0.00% 5 Missing ⚠️
pkg/egressproxy/deploy/create.go 83.87% 5 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 2a6f80f into main Nov 5, 2026
9 checks passed
@scttfrdmn
scttfrdmn deleted the feat/1515-sweep-detached-proxy branch November 5, 2026 23:28
@scttfrdmn

Copy link
Copy Markdown
Contributor Author

Live test: PASS (spore-host-dev 435415984226, us-east-1, released v0.160.0 CLI and orchestrator, no-NAT VPC)

Path Sweep Result
Submit and reuse dsw (4 Ubuntu rows, --max-concurrent 1) The CLI created proxy i-0addf8d4… and recorded it, and row 0 launched with spawn-egress-clients-<vpc>. Later sweeps' submits printed reusing ….
Forced re-create dsw After row 0, I ran egress-proxy delete --vpc, which terminated the proxy and deleted the proxy SG. The orchestrator logged hold: … is no longer reusable … launched egress proxy i-0a550319… and polled every 10 s (not ready after 10s…). It recreated the proxy SG, then launched rows 1–3. COMPLETED 4/4, 0 failed. The new proxy is a t4g.micro with spawn:version=0.160.0, and its log shows one CONNECT awscli.amazonaws.com from each of rows 1–3.
Cancel while creating dcx I terminated the proxy after row 0. The orchestrator launched i-0fa7c004… (creating), and I ran spawn cancel. That proxy was terminated 10 s after its RunInstances. CloudTrail shows both calls by assumed-role/SpawnSweepCrossAccountRole/spawn-sweep-orchestrator. Ready proxies were untouched.
Self-heal (unplanned) dto I revoked the proxy SG's 443/80 egress before the orchestrator's create. EnsureGroups restored both rules, the replacement became ready, and the sweep finished COMPLETED 2/2.
Timeout dto2 I revoked 443/80 egress after the replacement i-02390e77… launched (creating phase). About 6 minutes later the orchestrator terminated it, and the sweep ended 1 launched, 1 failed. The recorded reason: the egress proxy the sweep orchestrator launched for vpc-… did not become ready….

Teardown: All instances are terminated. egress-proxy delete removed both groups, and the VPC and endpoints are deleted. The leak diff against a pre-run baseline shows no new instances, SGs, Spot requests, EIPs or test VPCs. status --all-regions: none.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant