Repository navigation
fix(task): refuse user data over EC2's 16 KiB limit before any AWS call - #1247
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
…ll (#1063) task run and its --dry-run now build the exact gzip+base64 user data (launcher.BuildUserData, the bytes Provision sends) and refuse a spec over 16,384 decoded bytes before any AWS call; the dry run prints the size. One shared check (aws.CheckUserDataSize) also runs at the top of Client.Launch, in Provision before its AMI/IAM steps, and in the pipeline orchestrator Lambda. Fixes #1063
scttfrdmn
force-pushed
the
fix/1063-userdata-limit
branch
from
October 20, 2026 19:01
8eb6386 to
e7a3da7
Compare
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 #1063
What changed
pkg/aws. It addsMaxUserDataBytes(16384, applied to the bytes after base64 decoding, i.e. the gzip stream) andMaxEncodedUserDataBytes(25600, the base64 string), plusCheckUserDataSize,UserDataSize,*UserDataTooLargeErrorandLaunchConfig.ValidateUserDataSize. These are the two 400s quoted in task run: a spec over EC2's 16 KiB user-data limit passes --dry-run, then RunInstances fails with 400 #1063.Client.Launchcalls the check first, next toValidateDurationsand before its identity, pricing and AMI calls. That covers every path that goes through it:spawn launch, sweeps, job arrays, burst, pools, app, image, and Provision.launcher.BuildUserData(new, exported) returns the exact encoded user data thatProvisionsends.Provisionnow builds and checks the user data before the AMI lookup andSetupSporedIAMRole, since the bootstrap depends on neither. An oversized config therefore creates nothing.spawn task run:buildTaskLaunch. Both paths use it, so they measure the same bytes.taskUserDataPreflightruns right after sizing and before any AWS call (GetAccountIDincluded) in the real run, and in--dry-run. It uses placeholders of the same length for the account ID, the run ID and any FSx names.provisionTask.User data: N of 16384 bytes after gzip (EC2 limit).inputs:and to stage many per-file inputs as one directory prefix.generatePipelineUserData. It is hand-deployed, so this only takes effect once the Lambda is redeployed.make api-snapshot: additions only.Gates
Every gate counts HTTP requests through the AWS client's transport, so any AWS call is seen. None of them use wall-clock time.
TestTaskRunRefusesUserDataOverTheEC2Limitbinary-searches for the boundary. It measures independently, viabuildTaskLaunch, thenlauncher.BuildUserData, then base64 decode. The boundary falls at 2,676 incompressible command characters: 16384 B fits, 16385 B does not. It asserts:inputs:;runTaskRealrefuses 16385 B with 0 AWS requests;runTaskReallets 16384 B through: it reaches AWS and is not a size error.TestTaskUserDataPreflightMatchesTheLaunchchecks that the preflight measures the same bytes the launch builds.TestLaunchRefusesOversizedUserDataBeforeAnyAWSCallandTestProvisionRefusesOversizedUserDataBeforeAnyAWSCallassert 0 requests.TestCheckUserDataSizeLimitschecks the boundaries: 16384 passes, 16385 fails, and non-base64 input over 25600 fails.I watched each gate fail against a revert that compiles:
if false && ...): all of them fail;Finding, filed as #1246
A trivial task's user data is already 14,146 of 16,384 bytes, and the bare spored bootstrap alone is 12,488 B gzipped. So about 2 KB of compressed command plus inputs fit. This PR makes the failure early and clear, but it does not give back any headroom. The S3-carried bootstrap asked for in #1063's comments is tracked in #1246.
Not changed
spawn launch --dry-runstill reports only the custom user-data size. Its existing comment explains why: the full bootstrap needs a key pair that a real launch may create first. The realspawn launchis protected by theClient.Launchcheck, but only after its key, IAM and security-group setup, which are idempotent.Checks
make check: all tests pass.check-build-tagsfails on /private/tmp paths, and it fails the same way on unmodified main.make lint: 0 issues.semgrep --config=auto --error: 0 findings.make check-docs: clean.No AWS calls were made.