Repository navigation
Merged
Conversation
This was referenced Oct 15, 2026
Merged
…very instance, price the budget (#929, #930) Lambda's own region, and RunInstances in each stage's region was handed those groups, which do not exist there. The groups are now created in every region that needs one (the security group in every stage region, since it goes on every instance; the placement group in every EFA stage's region), recorded per region in PipelineState, used by each stage's launch from its own region, and deleted in that region. A group is recorded as soon as it exists, and a setup that fails part way is cleaned up. The pre-#929 single fields are read only for in-flight pipelines, in the Lambda's region. SSH was open to 0.0.0.0/0; it, like the streaming ports, is now allowed only from the group itself. instance_count > 1 the first to finish completed the stage and its siblings' FAILED went unread. Markers are per instance (StageInstanceMarkerKey), written by the runner and the user data fallback with the instance's index. The stage completes when every instance has written COMPLETE and fails on any FAILED or on any instance gone without COMPLETE. Legacy stage-level markers are still read (COMPLETE only for single-instance stages). The budget charged a flat $0.10/instance-hour, only at stage completion. Stages are now priced once at their on-demand rate via pkg/aws ResolveDisplayPrice (truffle; spot priced at on-demand, an upper bound), and the budget is checked each poll against finished stages plus running stages' elapsed instance-hours. With a budget, an unpriceable stage fails before launching. Notifications and `spawn pipeline status/list` label the figure an estimate. The template grants pricing:GetProducts. Tests: per-region create/use/delete with fake regional EC2, ingress limited to the group, legacy fallback, partial setup recorded; 4-instance stage completes only at 4/4 and its dependent waits, one FAILED or one vanished instance fails it, legacy markers; a p4d stage running an hour trips a $100 budget, unpriceable-with-budget launches nothing, cost labelled. The bash e2e now runs a failing stage as instance 1 of 2 and checks the per-instance FAILED and the orchestrator's verdict. Each gate was watched failing against a compiling revert.
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.
Fixes #929
Fixes #930
Stacked on PR A (#942, fix/910), which is stacked on #931 (fix/912). This PR's base is
fix/910. Merge in order: #931, then #942, then this.Cost safety. Found by reading the code and tested with fakes and the in-process Substrate emulator. No AWS resources, launches or deploys.
#929: network groups in each stage's region; SSH closed
What was wrong.
createStreamingSecurityGroupandcreatePlacementGroupused the Lambda's own region (us-east-1).RunInstancesthen ran in each stage's region with those group IDs. Groups are regional, so a streaming or EFA stage anywhere else would fail at launch. Cleanup deleted the groups in the Lambda's region, consistently with that. Separately, the group opened tcp/22 to0.0.0.0/0.What changed.
setupNetworkResourcescreates a security group in every stage region, because the group goes on every stage instance. It creates a placement group in every EFA stage's region. Both are recorded in the newPipelineState.SecurityGroupsandPlacementGroupsmaps, keyed by region.buildStageRunInstancesInputuses the stage's own region's group.cleanupNetworkResourcesdeletes each group in its own region. AWS calls go through anetEC2ForRegionseam.SecurityGroupID/PlacementGroupID. Those fields are read only for stages in the Lambda's region, and are cleaned up there.#930: every instance must complete; the budget is priced
Per-instance markers.
<prefix>/stages/<stage>/<instance-index>/COMPLETE|FAILED(pipeline.StageInstanceMarkerKey), with the index taken from the instance's tag. The user data's fallback FAILED marker does the same.checkStageOutcomecompletes a stage only when allinstance_countinstances have written COMPLETE. It fails the stage on any FAILED, or on any instance that has gone without writing COMPLETE: a spot interruption, say. The old rule waited for all instances to be gone. A completed instance that has since terminated itself does not count as a failure.Pricing.
calculateStageCostcharged a flat $0.10 per instance-hour, and only when a stage finished. Each stage is now priced once, at launch, at its on-demand rate. The lookup goes throughspawnaws.ResolveDisplayPrice(truffle: live Price List or its static table, the same authority--cost-limituses). The rate and its source are recorded onStageState.max_cost_usdset, a stage whose price cannot be determined fails before launching anything, following pkg/aws's rule that a limit that cannot be priced cannot be enforced. Without a budget, the stage launches unpriced and a warning is logged.spawn pipeline statusprints "Estimated cost … (finished stages, at on-demand rates)", and status/list use an "EST COST" column.template.yamlgrantspricing:GetProducts. Without it truffle falls back to its static table.Tests
New file
regions_markers_cost_test.go, plus an extension to the bash e2e from #942.stages/train/1/FAILEDfrom the instance's tag, andcheckStageOutcomefails the stage on it. The success test also asserts thatcheckStageOutcomereturns completed.p4d.24xlargeat $32.77/h, running for an hour, trip a $100 budget with no stage finished; all four are terminated and the stage's estimated cost is over $100. With the old flat rate, the cost is $0.40.Every gate was watched failing against a compiling revert (19 reverts, each
go vet-clean):0.0.0.0/0; legacy SG used in any region; cleanup in the Lambda region; SG not recorded;One addition has no gate: the cleanup after a failed setup is in
handler, which reads DynamoDB and S3 directly.Commands run.
make checkpasses except the known Docker-onlyTestGenerateWrapper_ChownFixesCrossUIDStickyUnlink_Docker.make check-nestedpasses (9 modules).go test -count=1 ./lambda/pipeline-orchestrator/ ./pkg/pipeline/passes (full, not short), and the orchestrator package also passes at-short -count=5.GOOS=linux GOARCH=arm64builds the Lambda.Deployment (not done here)
Deploy after #931 and #942. The template changed again, adding
pricing:GetProducts:cd lambda/pipeline-orchestrator AWS_PROFILE=spore-host-infra make deploy AWS_PROFILE=spore-host-infra make -C ../.. lambda-versions-deployedPer-instance markers are written by spored, so a spored release containing #942 and this PR must be published to
spawn-binaries-*along with the deploy. Until then, released spored writes the legacy stage-level key, and only single-instance stages complete. Multi-instance stages would wait for per-instance COMPLETE markers, fail when their instances exit, and be terminated. That is safe but wrong, so ship spored and the Lambda together. The CLI only changes labels here.Caveats and follow-ups
CreateSecurityGrouplands in a default VPC in each region. Stage launches pass no subnet, so they go to the default VPC; a region without one fails at setup, now visibly.efa_enabledattaches no EFA interface, and streaming between stages in different regions cannot connect, even with a group in each.output/prefix, so same-named outputs overwrite each other (pipeline data handoff: absolute data_output paths arrive nested under dest_path, and multi-instance stages overwrite each other's outputs #944).