Skip to content

fix(task): container memory floor + instance_health for Docker failures (#1180) - #1197

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/1180-container-memory-floor
Oct 19, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/1180-container-memory-floor

Conversation

@scttfrdmn

@scttfrdmn scttfrdmn commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Experiment E1 (#1171) found that a container TaskSpec with only resources.cpu sized to t4g.nano (0.5 GiB). On that box dnf install docker was OOM-killed in 3 of 3 runs, and the record said app_error / not retryable.

(a) Memory floor at sizing

  • taskproto.ContainerMemoryFloorGiB = 2. New method TaskSpec.SizingRequest() returns Resources with the floor applied when container is set and the effective memory (memory_gib plus headroom) is below 2 GiB.
  • It also applies when memory_gib is set lower than the floor. memory_gib describes what the workload needs. The Docker install needs memory on top of that, and the spec author can't be expected to know how much. A floored request is exactly the floor: the headroom is dropped so it doesn't become 2.4 GiB.
  • A pin is respected. A resources.instance_type pin is returned unchanged. spawn task run looks up the pinned type's memory (InstanceMemoryMiB, the same lookup the A box too small to run spored cannot enforce its own TTL: 0.5 GiB instance outlived a 6m TTL by 2x, silently #682 spored-floor warning uses) and prints a warning to stderr if it's below the floor.
  • taskproto.Size now also drops candidates whose known memory is below the requested memory. Before, it trusted the finder's MinMemory filter, so the floor now holds even if a finder ignores it.
  • The dry run prints a note when the floor raised the request.
  • Both taskproto.Size call sites in cmd/task.go now pass spec.SizingRequest().

Why 2 GiB. E1 measured only two sizes: 0.5 GiB failed 3/3, and 4 GiB passed 3/3 with a ~66 s install. Nothing in between has been measured. 1 GiB is already the point below which spawn warns that AL2023's own dnf transactions are unreliable (aws.SporedMemoryFloorMiB, #682). A container task runs that transaction plus a resident dockerd/containerd plus the workload, so flooring at exactly the bare-dnf line would leave no headroom. 4 GiB is the only measured-good value, but it would double the cheapest container box for every cpu-only container task on an unmeasured margin. 2 GiB is the smallest standard size (t4g.small, t3.small) above the 1 GiB line. The 2 GiB value has not been measured on AWS. Follow-up: #1199.

(b) Docker failures are not app errors

  • In pkg/taskproto/wrapper.go, a failure of dnf install -y docker, systemctl enable --now docker, or the 30-try docker info wait now sets RUNTIME_RC. The wrapper then skips the pull and run, sets rc, and the classifier records instance_health. It checks this after STAGE_RC and before rc. Before, each step's failure was ignored: the wrapper ran sudo docker run anyway, got "command not found", and recorded app_error.
  • Why instance_health and not staging_error. staging_error is documented as "an input S3 copy failed" and not retryable, and making it retryable would change the semantics for S3 input failures. instance_health was already defined and listed in the adapter RFC but nothing produced it. This is its first producer, and it's now retryable, so nothing that existed before changes behaviour. None of the Python or Java adapters switch on specific classes; I grepped the sibling repos.
  • The GPU toolkit block and the ECR login now run only when the runtime came up. A toolkit-install failure is still not escalated, because that's outside this issue.

Gates, each watched failing against a compiling revert

  • TestGenerateWrapper_ContainerRuntimeFailureIsNotAppError (pkg/taskproto/wrapper_runtime_test.go) runs the whole generated wrapper under bash. PATH is only a stand-in directory, so a real docker on the CI host can't skip the install. It has three cases: dnf exits 137 with docker absent, docker info never succeeds, and systemctl fails. Each asserts state failed, a class that is neither app_error nor empty, that the class is retryable, exit_code != 0, and that docker pull/run was never invoked.
    • Revert 1 removed the RUNTIME_RC elif from the classifier: all three cases fail with retry_class = "app_error".
    • Revert 2 dropped the || RUNTIME_RC= captures: dnf case app_error, the other two "".
  • The control TestGenerateWrapper_ContainerCommandFailureStaysAppError checks that with a working runtime, a command exiting 3 is still app_error/3.
  • TestRenderTaskDryRun_ContainerCPUOnlySizesAtFloor uses a fake finder that returns the whole t4g ladder regardless of the request. A cpu-only container spec picks t4g.small and the dry run explains why. The same spec without a container still picks t4g.nano.
  • TestRunTaskReal_ContainerAsksFinderForFloor uses a recording finder that stops the run. For both the real path and the dry-run path, the finder is asked for at least 2 GiB. runTaskReal sizes before touching AWS, so this test makes no AWS call.
  • TestCmd_TaskprotoSizeUsesSizingRequest is an AST check. It discovers every taskproto.Size call in cmd/*.go (excluding tests) and fails if it finds none. Each call's request argument must be <x>.SizingRequest().
  • TestSizingRequest_ContainerMemoryFloor and TestSize_FiltersCandidatesBelowRequestedMemory are unit tests in pkg/taskproto.
  • TestContainerPinBelowFloorWarns covers the warning cases: a pinned nano warns; a pin at the floor, a host task, an unpinned spec, and an unknown memory lookup don't.

Reverts:

  • R1 (floor disabled with if false && ...): the SizingRequest, Size-filter, dry-run and finder tests fail.
  • R2 (call sites back to spec.Resources): the dry-run, finder and AST tests fail.
  • R3 (the Size memory filter disabled): the Size-filter and dry-run tests fail.

Checks

  • make check passes steps 1–6. Step 7 check-build-tags fails here exactly as it does on an unmodified main worktree (the /private/tmp path issue).
  • make gen-docs was run, and the help text change is committed. make check-docs is clean.
  • make api-snapshot adds ContainerMemoryFloorGiB and (*TaskSpec).SizingRequest. Nothing was removed.
  • semgrep scan --config=auto --error . is clean.
  • Nothing was run on AWS.

API note

spore-host-mcp calls taskproto.Size(ctx, finder, spec.Resources) and won't get the floor until it switches to spec.SizingRequest() after the next spawn release. The Size-side filter doesn't help it either, because with spec.Resources the requested memory is 0. Filed as spore-host/spore-host-mcp#60.

Fixes #1180

@codecov

codecov Bot commented Oct 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.91525% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/task.go 90.00% 2 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

…es (#1180)

A container spec with only resources.cpu sized to t4g.nano, where the
boot-time dnf install docker is OOM-killed, and the record blamed the
application (app_error, not retryable).

- Sizing: TaskSpec.SizingRequest() applies a 2 GiB floor
  (ContainerMemoryFloorGiB) to container tasks, also when memory_gib is
  lower; Size drops candidates below the requested memory. A pinned
  instance_type is honoured, with a warning below the floor.
- Wrapper: a failed Docker install, service start or daemon wait sets
  RUNTIME_RC, skips pull/run, and classifies instance_health, now
  retryable.

Fixes #1180
@scttfrdmn
scttfrdmn force-pushed the fix/1180-container-memory-floor branch from b88373b to 0b864c3 Compare October 19, 2026 22:50
@scttfrdmn
scttfrdmn merged commit 41d208c into main Oct 19, 2026
8 checks passed
@scttfrdmn
scttfrdmn deleted the fix/1180-container-memory-floor branch October 19, 2026 23:08
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.

task run: a container task at default sizing fails, because Docker's install is OOM-killed on t4g.nano (and is classified app_error)

1 participant