Skip to content

Attach EFA interfaces to efa_enabled pipeline stages; reject cross-region streaming (#956) - #988

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/956
Oct 17, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/956

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Fixes #956

Stacked on #980 (fix/944). This PR's base is fix/944. Merge in order: #931, #942, #957, #972, #980, then this.

Cost safety. Found by reading the code, then tested with fakes. No AWS resources were created, nothing was launched and nothing was deployed. Every test run used no AWS credentials (see spawn#968).

1. efa_enabled attaches no EFA

What was wrong. buildStageRunInstancesInput handled efa_enabled by adding the cluster placement group only. The instances got an ENA interface, and fi_info -p efa found nothing. EFA also needs a security group that admits all traffic from itself. The pipeline group was created only for streaming pipelines, and opened only tcp 50000-60000 and 22.

What changed.

  • EFA stages are launched with pkg/aws.EFANetworkInterface: the primary interface, type efa, public IP, deleted on termination.
    • This is exactly the interface spawn launch --efa builds. It is extracted from client.go, so that path is unchanged, as the issue suggested.
    • The pipeline's group goes on the interface, not on SecurityGroupIds, because RunInstances rejects instance-level groups alongside NetworkInterfaces. The test asserts both.
  • The pipeline group is now created in every EFA stage's region, whether or not anything streams.
  • Instance type check. spawn pipeline launch checks every EFA stage's type with the existing ValidateInstanceTypeForEFAInRegion (EC2 DescribeInstanceTypes in the stage's region), before it creates anything. Otherwise a bad type would fail mid-pipeline, after earlier stages had been billed.
    • I looked for a truffle capability to reuse. truffle v0.58.0 has none for EFA outside its CLI (cmd/), so this uses the EC2 API that spawn launch --efa already uses.
    • It runs in the CLI rather than the Lambda, so the Lambda needs no ec2:DescribeInstanceTypes.
  • ml-training.json used p3.8xlarge, which has no EFA, so the check would have refused it. It now uses p3dn.24xlarge.

2. Cross-region streaming: rejected at validation

Why reject, not support.

What changed.

  • Pipeline.Validate, used by spawn pipeline validate and launch, rejects a stream-mode data_input whose source_stage is in another region. The error names both stages and regions and says to use "mode": "s3" or one region.
  • Regions are compared through Stage.EffectiveRegion(), so a stage with no region counts as us-east-1. pipeline.DefaultStageRegion is now the orchestrator's defaultStageRegion too, so the two cannot disagree.
  • s3 mode across regions is unaffected.

Docs. examples/streaming/README.md documents the same-region requirement, the 50000-60000 port range, and what efa_enabled now does. Its "See Also" pointed at two docs/ pages that do not exist. It now points at examples/pipelines/README.md.

Tests (each watched failing against a revert that compiles)

revert fails
no EFA interface TestEFAStageIsLaunchedWithAnEFAInterface
EFA interface plus instance-level groups TestEFAStageIsLaunchedWithAnEFAInterface
no all-traffic self rule TestEFARegionGroupAdmitsAllTrafficFromItself, TestNonEFAGroupDoesNotAdmitAllTraffic
group only for streaming pipelines TestEFAStageIsLaunchedWithAnEFAInterface, TestEFARegionGroupAdmitsAllTrafficFromItself
no cross-region check TestValidateRejectsCrossRegionStreaming
raw Region compare ("" vs us-east-1) TestValidateAllowsSameRegionStreamingAndCrossRegionS3
EFA check skips stages TestLaunchChecksEFAStagesBeforeCreatingAnything
check call removed from launch TestLaunchRunsTheEFACheckFirst
  • TestEFANetworkInterface covers the shared helper.
  • TestNetworkResourcesAreCreatedAndUsedInEachStagesRegion now reads an EFA stage's groups from its interface.
  • api/public-surface.txt was regenerated with make api-snapshot. It is an addition only (EFANetworkInterface), recorded under CHANGELOG Added.
  • make check: all pass except the known Docker-only TestGenerateWrapper_ChownFixesCrossUIDStickyUnlink_Docker.
  • make check-nested: clean.
  • go test -count=1 ./lambda/pipeline-orchestrator/ ./pkg/pipeline/ ./pkg/aws/: pass.

Deploy

  1. Redeploy spawn-pipeline-orchestrator (make -C lambda/pipeline-orchestrator deploy). It needs no new IAM: ec2:RunInstances on * covers the network interface, and the security group calls were already granted.
  2. Release the CLI, for the cross-region refusal and the EFA type check.

Caveats

  • Only the primary network card gets an EFA interface, as with spawn launch --efa. Multi-card types (p4d, p5) need one EFA interface per card for full bandwidth. That is a limitation of the shared helper, not new here.
  • This has not been run on real EFA hardware. Whether fi_info -p efa reports a provider also depends on the AMI having the EFA driver. Stages without an ami use the recommended AMI, which may not include it.
  • The orchestrator does not re-validate definitions. A pipeline launched by an older CLI with a cross-region stream still launches and cannot connect, as before.

…gion streaming (#956)

buildStageRunInstancesInput handled efa_enabled by adding the cluster
placement group only, so stage instances got an ENA interface. It now
attaches pkg/aws.EFANetworkInterface, the interface `spawn launch --efa`
builds (extracted from client.go, behaviour unchanged there), with the
pipeline's group on the interface, since RunInstances rejects
instance-level SecurityGroupIds alongside NetworkInterfaces. EFA needs a
group admitting all traffic from itself: the pipeline group is now
created in every EFA stage's region, streaming or not, and in such a
region carries an all-traffic self rule (still nothing open to an
address range). `spawn pipeline launch` checks each EFA stage's type
with ValidateInstanceTypeForEFAInRegion (EC2 DescribeInstanceTypes; no
truffle EFA capability exists to reuse) before it creates anything.
ml-training.json's p3.8xlarge has no EFA; it uses p3dn.24xlarge.

Cross-region streaming cannot connect: each region has its own default
VPC and pipeline group, peer discovery publishes private IPs, and
nothing peers the VPCs. Building that (peering, or public ingress for
the peers' addresses) is not a small change, so Validate rejects a
stream-mode data_input whose source stage is in another region, with
an error naming both regions and pointing at s3 mode. Stage regions are
compared through Stage.EffectiveRegion (DefaultStageRegion, now shared
with the orchestrator).

Each guard watched failing against a compiling revert. (#956)
@codecov

codecov Bot commented Oct 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.84211% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
lambda/pipeline-orchestrator/main.go 88.23% 2 Missing and 2 partials ⚠️
cmd/pipeline.go 80.00% 2 Missing ⚠️
pkg/aws/client.go 0.00% 2 Missing ⚠️
pkg/pipeline/pipeline.go 89.47% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit ce15ebc into main Oct 17, 2026
8 checks passed
@scttfrdmn
scttfrdmn deleted the fix/956 branch October 17, 2026 05:26
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.

pipeline: efa_enabled attaches no EFA interface, and stream handoff between stages in different regions cannot connect

1 participant