…ough the proxy (#1515 phase 4)
With --bootstrap-egress proxy, the EFA installer download and run, spawn's
own apt-get, and the AWS CLI zip's origin fallback go through the egress
proxy, each command by itself; the S3 mirrors, AL2023's S3 repos and every
AWS endpoint bypass it through a no_proxy derived in code. The user's
--command and --mpi-command never see the variables. Members whose own
security groups allow no egress to tcp 3128 on the proxy are refused before
any is created. Without a proxy address the user data is byte-identical,
and the published bootstrap body is unchanged.
Refs #1515
Refs #1515 (phase 4 of the build plan: members fetch through the proxy).
What this does
With
--bootstrap-egress proxy(soLaunchConfig.EgressProxyAddris set byensureEgressProxy), a member setshttp_proxy/https_proxy/no_proxyonly for spawn's own fetches from outside AWS. Nothing is exported, nothing goes to/etc/environmentorprofile.d, and--command,--mpi-commandand--user-datanever see the variables.curl, mirror then origin)spawn_px curl ...: the variables prefix that one command.no_proxynames S3, so curl fetches the regional mirror directly and onlyefa-installer.amazonaws.comgoes through the proxy./efa_installer.sh(its own dnf on AL2023, apt-get on Ubuntu)spawn_px ./efa_installer.sh -y -g. AL2023's repos are S3 buckets, whichno_proxysends directapt-get update/install(the MPI apt path and the pre-EFA refresh from #1491)-o Acquire::http::Proxy=http://<addr>/ -o Acquire::https::Proxy=http://<addr>/SPAWN_PX_REGION=<r>; http_proxy=… https_proxy=… no_proxy=… spawn_need_aws "$SPAWN_PX_REGION" || true, before the body. The mirror is still tried first, directly; only theawscli.amazonaws.comfallback goes through the proxy. The body's ownspawn_need_awsthen finds the CLI installed and returnsspawn_px() { http_proxy=… https_proxy=… no_proxy=… "$@"; }: in bash, assignments that prefix a command reach only that command's environment, so they are gone when it returns. The function isn't exported, so mpirun and ssh never see it.no_proxy, derived in code (pkg/aws.EgressProxyNoProxy)169.254.169.254, localhost, 127.0.0.1, .s3.amazonaws.com, .s3.<r>.amazonaws.com, .s3.dualstack.<r>.amazonaws.com, s3.<r>.amazonaws.com, plus<svc>.<r>.amazonaws.comfor every otherprivateServicesendpoint: ec2, ssm, ssmmessages, ec2messages, dynamodb, fsx, sqs, xray..amazonaws.com, becauseefa-installerandawsclimust reach the proxy.sts).amazon-linux-repo-s3-2023.12.20261021in anamazonlinux:2023container. Its mirrorlist ishttps://al2023-repos-$awsregion-de612dc2.s3$dualstack.$awsregion.$awsdomain/..., with/etc/dnf/vars/dualstack=.dualstack. Both the dualstack and the plain form are covered. The container image itself ships-repo-cdn(cdn.amazonlinux.com), which no EC2 member uses.pkg/egressproxy.NoProxyBypassesmirrors curl's rule fromlib/noproxy.c(7.86+): comma/space separated, one leading and one trailing dot ignored, an exact match or a match on a.-bounded suffix, IP/CIDR matching only for IP hosts, and*.TestEgressProxyNoProxySparesTheAllowlistchecks three regions: everyegressproxy.Allowlisthost goes to the proxy, and every S3, AL2023-repo and endpoint host bypasses it.Member SG egress preflight
deploy.CheckMemberEgressruns right afterMemberGroups, before any member exists. It refuses unless at least one of the member's groups has egress (all traffic, or a TCP range containing 3128) to:Prefix-list destinations aren't counted. The refusal names every group (
sg-… (name)), and never blames the clients group, which has no rules by design.grep RevokeSecurityGroupEgress). The MPI, Windows,--efa-groupand VPC default groups keep EC2's allow-all egress, andensureMPIClusterRulesonly adds a self rule.ec2:DescribeSecurityGroups, already in the launch IAM.make cli-iam-actionsproduced no diff.Readiness
Unchanged. #1518's ordering still holds:
ensureEgressProxy(now with the egress check) runs beforebuildUserDataand before any RunInstances. Every member is cloned from that config.The signed bootstrap body: unchanged
BootstrapBody()hashes the same as main (73d1876b…c049). The AWS CLI proxying lives in the per-launch part (perLaunchPreBody). On the stub path, the user data also carries thespawn_need_awsdefinition when a proxy is set (about 1 KB raw, ~0.5 KB gzipped), as the staged-files path already does.Why there and not in the body:
spawn_need_aws "$REGION"returns at once.Without the opt-in: byte-identical
GenerateMPIUserData(EFA rank 0 and peer, plain,--skip-mpi-install, a no-mirror region) andBuildLinuxBootstrap(stub, inline) onorigin/mainand on this branch. All sha256s are identical.TestNoEgressProxyRendersUnchanged(MPI) andTestEgressProxyLeavesTheBodyAndAPlainLaunchUnchanged(bootstrap) assert this structurally: removing exactly the proxy insertions from a proxied render gives the plain render byte for byte, and the plain render names no proxy at all.Tests
Sandbox (
pkg/userdata/mpi_egress_proxy_test.go). The stand-incurl,apt-get,yumandefa_installer.shnow log the proxy variables they ran with. The cases run on AL2023 (yum base), Ubuntu (apt base) and theubuntu:24.04container, and assert:efa_installer.shsawhttp(s)_proxyand exactly the derivedno_proxy, which bypasses the AL2023 repo hosts and proxies the Ubuntu mirrors;apt-getcarried theAcquireoptions;--mpi-command, on all 3 ranks, saw no*_proxyvariable;/etc/environmentorprofile.dfile names the proxy.Other tests:
pkg/launcher/bootstrap_egress_proxy_test.go): full boot with a recording curl wrapper. Mirror missing: the mirror is fetched direct, then the origin through the proxy. Mirror present: one fetch, direct. The IMDS curls,--commandand--user-datasee no proxy env. On the stub path,spawn_need_awsis defined before the call, and the call comes before the staged fetch and the body.TestMemberUserDataCarriesTheProxychecks the bootstrap and the MPI script throughbuildUserDataandbuildJobArrayMemberConfig, with and without an address.TestEnsureEgressProxyChecksMemberEgressandTestLaunchRefusesMemberGroupsThatCannotReachTheProxycheck that the refusal comes before RunInstances (withwithLogDir).TestCheckMemberEgress,TestNoProxyBypasses,TestEgressProxyEnvandTestEgressProxyAddrIsValidated. The address must be IP:port and the region a plain region name, since both are rendered unquoted. The shellcheck matrix adds two proxy configs.Revert evidence
Each key decision was reverted with a change that compiles. The named tests failed in 20 of 20:
apt-get updatewithout Acquire optionsexported globallyno_proxyon all 3 ranks).amazonaws.comin no_proxy.boundary)spawn_need_awsdefinitionChecks
make checkpasses.go test ./...passes (AWS env stripped,/dev/nullconfig).semgrep scan --config=auto --error .is clean.make api-snapshotandmake gen-docswere regenerated. The--bootstrap-egresshelp now says what is proxied and that member groups need egress to tcp 3128, with no backticks.Not run against AWS
Nothing here touched AWS. The owner runs the live test: AL2023 and Ubuntu 24.04
--mpi --efain a no-NAT VPC.