Skip to content

feat(launch): --bootstrap-egress proxy on foreground parameter sweeps (#1515 PR A) - #1531

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

scttfrdmn merged 4 commits into
mainfrom
feat/1515-sweep-foreground-proxy

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Refs #1515

PR A of sweep support for --bootstrap-egress proxy (owner plan, 2026-11-05): foreground parameter sweeps. Detached sweeps and the orchestrator are PR B.

Design

  • Per-member check, then find-or-create per (region, VPC). ensureSweepEgressProxies reruns each member's --no-public-ip check from the client's cache, in the member's own region and subnet. It groups the members whose check has ViaEgressProxy by (region, VPC), then calls deploy.FindOrCreate once per VPC, one VPC at a time, in first-appearance order. Each such member then gets its VPC's EgressProxyAddr and MemberGroups, and must pass CheckMemberEgress. A member with no proxy need (NAT route, AL image, not opted in) gets nothing. A sweep with no such member makes no proxy.
  • Placement: after the subnet check and IAM setup, before renderForegroundSweepUserData, which bakes the address into the bootstrap. So the proxy is ready before any member launches.
  • Failure: if any VPC's proxy isn't ready, or a member can't reach its VPC's proxy, no member is launched. FindOrCreate already terminates the failed VPC's new proxy. The sweep also terminates the proxies it created in other VPCs, and leaves reused ones alone. The error ends with "no member was launched".
  • Idle: --egress-proxy-idle, with the same default and cap (validated in validateBootstrapEgressFlags).
  • Resume: spawn resume/spawn sweep resume of a foreground sweep runs the same step before relaunching, with the idle period recorded in the checkpoint (SweepMemberRecord.EgressProxyIdle).
  • Detached still refused. The refusal happens before any AWS call and covers the flag, SPAWN_BOOTSTRAP_EGRESS and the config default. It applies to every sweep without --no-detach, since a sweep is detached by default. The message names Managed egress proxy for --no-public-ip bootstraps (no NAT gateway, no mirrors) #1515 and --no-detach. All of it is one function, refuseDetachedSweepEgressProxy, with three call sites for PR B to delete: runLaunch, the dispatch backstop in launchParameterSweep, and detachedSettingsGuard. spawn schedule create takes neither --no-public-ip nor the opt-in.

Refactor of the single path

ensureEgressProxy is split into egressProxyNeed (the cached preflight), findOrCreateEgressProxy(region, network, idle), and egressProxyFor.attach and .report. The single, job-array and MPI paths call them in the same order with the same messages, and the existing tests pass unchanged. A new seam, egressProxyTerminate, wraps deploy.Terminate.

Fix found on the way

The foreground sweep's --no-public-ip check ran before AMI and OS detection. Every member without an ami: therefore counted as "image not named yet, may have no aws CLI", and Windows members were checked as Linux. It now runs after them, as on a single launch. The existing order gate still holds: after resolveSweepEFA, before EFA subnets and the SSH key.

IAM

spawn resume and spawn sweep resume gain ec2:CreateSecurityGroup, DescribeSecurityGroups, Authorize/RevokeSecurityGroupIngress/Egress. spawn launch already calls all of them, so no CLI user needs a new action. docs/reference/cli-iam-actions.md is regenerated. The cross-account role is untouched (that's PR B).

Tests (hermetic)

In cmd/launch_sweep_egress_proxy_test.go:

  • two VPCs in two regions: one FindOrCreate each, the right address and SG for each member, none for the NAT member or the one not opted in;
  • no need, no proxy;
  • one VPC fails: zero members get a proxy, the other VPC's created proxy is terminated, a reused one is not;
  • member-egress refusal names its parameter set and tears down;
  • preflight error names the parameter set;
  • report lines;
  • wired through runLaunch --param-file --no-detach: one FindOrCreate with --egress-proxy-idle, zero RunInstances on failure (withLogDir);
  • detached refused via flag and env, with --detach and with the default, and with zero AWS calls;
  • guards;
  • record idle;
  • source-order gates.

The disposition and coverage tables are updated: foreground BootstrapEgress is now direct, EgressProxyAddr is user data.

Revert gates: each of the following was reverted and made its test(s) fail. Removing the ensure call, grouping regardless of VPC, removing the teardown, tearing down reused proxies, removing the runLaunch refusal, treating every opted-in member as needing a proxy, removing the detached guard.

Checks: make check, hermetic go test ./..., go test -tags e2e_tier0 ./test/e2e/, semgrep scan --config=auto --error ., make gen-docs, make api-snapshot (no change), make cli-iam-actions.

@codecov

codecov Bot commented Nov 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.27273% with 14 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/launch_egress_proxy.go 92.30% 7 Missing ⚠️
cmd/launch_sweep.go 50.00% 4 Missing ⚠️
cmd/resume.go 0.00% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn

Copy link
Copy Markdown
Contributor Author

Live test at 55d2140c: PASS (aws account, us-east-1, one no-NAT VPC, spored v0.159.0)

# Check Result
7 Refusals ✅ Each of these was refused before any AWS call, with the message naming #1515 and --no-detach: --bootstrap-egress proxy with --detach, the same with the default (detached), and SPAWN_BOOTSTRAP_EGRESS=proxy with --detach. 0 instances in the VPC.
2 Ubuntu 24.04 foreground sweep, 2 × t4g.small, --bootstrap-egress proxy --egress-proxy-idle 30m --no-detach ✅ One find-or-create for the VPC: launched egress proxy i-0f76eef6…, ready in 234 s. Both members launched after it, each with default,spawn-egress-clients-<vpc>. A member ran aws --version, printed aws-cli/2.39.3 (installed by the bootstrap), and SPAWN_COMPLETE = completed/command/0. The proxy log shows one CONNECT awscli.amazonaws.com from each member IP plus the readiness probe.
3 Rerun the same sweep ✅ reusing i-0f76eef6…, and both members launched.
4 AL2023 foreground sweep with the opt-in ✅ No proxy step, no new proxy, and both members launched. This confirms the subnet check now runs after AMI detection.
5 AL2023 foreground sweep without the opt-in ✅ Accepted and launched; no proxy.
9 Teardown ✅ egress-proxy delete --vpc terminated the proxy and deleted both groups. The VPC is deleted. Leak diff against a pre-run baseline: no new instances, SGs, Spot requests, EIPs or test VPCs. status --all-regions: none in 18 regions.

Not run live:

Found along the way (pre-existing, not this PR): a --param-file sweep without a CLI --instance-type takes the wizard path and refuses --no-public-ip, and the examples omit the required spore name. Filed as #1532.

@scttfrdmn
scttfrdmn merged commit 77cf485 into main Nov 5, 2026
9 checks passed
@scttfrdmn
scttfrdmn deleted the feat/1515-sweep-foreground-proxy branch November 5, 2026 22:28
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