Skip to content

A task whose command fails writes no completion record at all, so the box rides to TTL instead of self-terminating #566

Closed

Description

@scttfrdmn

What happened

Two tasks failed inside the container (exit 1 from the user command, cause in #565). Neither ever produced a completion record, and neither box self-terminated on failure — both sat until TTL.

Measured, cookbook-salmon-quant-r1, spawn 0.102.0 / 3db242c, AL2023 arm64 c8g.2xlarge:

time (UTC) event
17:31:51 instance launched, TTL 20m, on_complete: terminate
17:32:50 container starts; inputs verify; user command exits 1
17:51:51 TTL elapses
~17:52 instance terminated by TTL
— s3://spawn-results-…/tasks/cookbook-salmon-quant-r1/ — prefix never created

Checked repeatedly across those 20 minutes: no completion.json, no .exitcode, no command.log, no prefix at all. Same for the sibling task cookbook-star-align-r1 (still running toward its 30m TTL as I write this).

The five tasks in the same batch whose commands succeeded all wrote their records and self-terminated within a minute of finishing, so this is specific to the failure path.

Why this contradicts the intended design

pkg/taskproto/wrapper.go is explicit that the failure path is supposed to be covered:

  • wrapper.go:25-27 — "We do NOT set -e. Under -e the script would abort the instant the user command exits non-zero, so stage-out and the completion record would never run — defeating the purpose."
  • wrapper.go:64 — emits that same note into the script.
  • wrapper.go:112 — "stage-out (only when the command actually ran; runs even if it failed)".
  • wrapper.go:126-132 — classification explicitly has an elif [ "$rc" -ne 0 ] branch setting STATE='failed' / RETRY_CLASS=app_error.
  • wrapper.go:154, :158 — completion.json and .exitcode copied with || true.
  • wrapper.go:166 — /tmp/SPAWN_COMPLETE written with "status": "$STATE", which is what drives on_complete.

So a failing command should produce state: failed, exit_code: 1, retry_class: app_error and self-terminate. Observed: neither. The wrapper appears not to reach the block after writeContainerRun's rc=$?. Console output stops at the container teardown with no aws s3 cp output following, which is consistent with that but is not proof — the serial console capture may simply not carry it.

I have not instrumented further: from outside the box I can only observe absence, and guessing at the mechanism is your call to make with a log in hand.

Impact, in order

  1. A failed task is indistinguishable from a stage-in failure. Both present as "no completion record." The docs and my own project rules say no-record means probable stage-in failure; that heuristic is now wrong, and there's no way to tell them apart from S3.
  2. --wait burns the entire TTL on a task that failed in the first minute. It reports correctly when it gives up — timed out waiting for task "…" completion record (past TTL); poll later with 'spawn task status …', exit 1 — but that arrives 19 minutes after the answer was knowable.
  3. Spend. 20 min billed for 60 s of work, ×3 boxes here. Bounded, not stranded — TTL fired reliably, which is the part that works and is worth keeping.
  4. retry_class: app_error never reaches anything that consumes it, so a caller cannot distinguish retryable from not.

This is the counterpart to #561: there, a task with a missing output is recorded completed / exit_code: 0 (a green check over nothing); here, a task with a failing command is recorded as nothing at all. Together they mean the completion record cannot currently be trusted in either direction on the failure path.

What would settle it

A bash -x of the generated wrapper around the writeContainerRun boundary on a task whose command exits non-zero on purpose — e.g. command: ["bash","-c","exit 3"] with one declared output. That should be a two-minute reproduction and does not need a real payload.

Filed from the scientific-codes-cookbook project.

Activity

  1. scttfrdmn commented on Sep 3, 2026

    @scttfrdmn
    ContributorAuthor

    Second sighting, and it widens the finding

    A third task hit the same signature, but failed at a different place, which is the part that matters.

    cookbook-salmon-quant-r1, retry, spawn 0.102.0 / 3db242c, c8g.2xlarge, TTL 20m:

    time (UTC) event
    18:00:40 instance launched
    18:01:13 cloud-init finishes (27.7s), spored installation complete
    — nothing further. No dnf install docker, no docker pull, no wrapper output at all
    18:12:30 spawn task status cookbook-salmon-quant-r1 → running (no completion record yet)
    18:22:18 terminated by TTL
    — tasks/cookbook-salmon-quant-r1/ — prefix never created

    Console output on this box carries kernel/audit lines through 334s, so the console was capturing; the wrapper's own output simply never appears. On the two earlier boxes the same console did carry dnf install, docker pull and the task's stdout, so this is not a capture artifact. The task script appears never to have started.

    An identical-shape sibling task (cookbook-star-align-r1, same edit, same image family, launched 40s later) ran clean and wrote its record, so this is not the spec.

    Why this widens it rather than just confirming it

    The original report was "a task whose command fails writes no record." This box's command never ran. So the missing-record signature now covers at least three distinct failure locations:

    1. stage-in failure (documented behaviour, retry_class: staging_error)
    2. user command exits non-zero (original report)
    3. task script never starts at all (this one)

    All three present identically from the outside: no completion.json, no .exitcode, no command.log, no prefix, status reporting running, box riding to TTL. The absence of a completion record therefore carries no diagnostic information whatsoever — it cannot distinguish "never started" from "failed" from "still working." That is a stronger claim than the original issue made, and it is what makes --wait expensive: 21.6 minutes billed here for a box that did nothing after second 27.

    Also worth separating out: spawn task status reporting running for a box that has produced nothing for 11 minutes is reporting intent, not observed state. Something cheap that reflects reality — instance still alive vs. wrapper heartbeat vs. no signal since T — would let a caller give up early instead of paying out the TTL. Happy to file that separately if you'd rather keep this issue scoped to the record itself.

    TTL fired reliably in all three cases, so spend stayed bounded. That part continues to work.

  2. scttfrdmn commented on Sep 3, 2026

    @scttfrdmn
    ContributorAuthor

    Naming the pattern, since this is now the third instance in the same family. Not a new report — recording it here so a fourth sighting has something to attach to.

    All three are spec-and-status handling that reports success or silence instead of the truth, and none of them are in the launch path:

    1. Task path discards failure information: a lost output is reported as completed/exit 0, and a stage-in failure can produce no record at all #561 — a task whose declared output fails to stage is recorded state: completed, exit_code: 0. The wrapper computes the stage-out result and discards it. Green check over a missing object.
    2. This issue (A task whose command fails writes no completion record at all, so the box rides to TTL instead of self-terminating #566) — a task whose command fails writes no completion record at all, so stage-in failure, non-zero command exit, and "task script never started" are indistinguishable from S3, and the box rides to TTL. Absence of a record carries no diagnostic information. Also spawn task status reporting running for an idle box: intent, not observed state.
    3. TaskSpec is silently narrower than spawn launch: unknown fields ignored, no root disk, no cost cap, arm64 sizes to a1 #556/fix: TaskSpec no longer silently narrower than launch (#556) #558 (fixed in 0.103.0) — worse than it looked from outside. Verified against 8a2f45d: resources.disk_gib and lifecycle.cost_limit did not exist as TaskSpec fields, and ParseSpec discarded unknown keys silently. So a spec requesting a larger root disk or a cost cap parsed clean, passed Validate(), and launched with neither — silent on both. The DisallowUnknownFields fix is the right shape precisely because it converts a silent narrowing into a parse error.

    The shared root cause is that the TaskSpec/status surface treats "I could not do what you asked" as a non-event, while the launch path generally errors. The fix shape that worked for #558 — make the discrepancy loud at parse or record time rather than inferable afterwards — is probably the fix shape for #561 too: stage-out failure should set the state, not be discarded.

    No action requested beyond #566 itself. Flagging the family because two of the three cost a box to discover, and the diagnostic path for all three was "read the console output," which is not something a caller can automate against.

  3. scttfrdmn commented on Sep 4, 2026

    @scttfrdmn
    ContributorAuthor

    Fourth sighting, and I think there's a fix that closes the class rather than the instance

    Filed #570 today for an unrelated reason (a container task can't see a mounted EFS) and its secondary finding belongs here instead, because it's this pattern again:

    {"inputs": [{"source": "/efs/refs/GRCh38.fa", "destination": "/tmp/GRCh38.fa"}]}

    Validate requires only that both fields are non-empty (pkg/taskproto/taskspec.go:203–207), and the wrapper emits aws s3 cp unconditionally (wrapper.go:117, :173). So that spec parses, validates, passes --dry-run, launches, boots, installs Docker, and only then dies in stage-in on ParamValidation: usage: aws s3 cp <LocalPath> <S3Uri> .... Since #558 added DisallowUnknownFields this isn't even a dropped unknown key — it's a known field holding a value nothing downstream can execute.

    The family, as I read it

    Two distinct axes keep getting conflated, and separating them suggests different fixes:

    Axis A — the spec was knowably wrong before the instance existed, and you pay a boot to find out.

    knowable at found out at
    #556 / #558 — disk_gib / cost_limit silently dropped parse never (a guardrail you believe is armed)
    #570 secondary — non-s3:// manifest entry parse after boot + Docker install

    Axis B — the task ran and the record lies about it.

    #561 declared output fails to stage → completed, exit_code: 0
    #566 (this one) command fails → no record at all, ride to TTL

    Axis B needs the wrapper/record fix this issue is about. But Axis A is entirely a validation problem, and it's the cheaper half: every instance of it is a Validate that accepts a value no downstream consumer can act on.

    Concretely

    Validate already does exactly the right thing in one place:

    for i, u := range s.Resources.S3ReadWrite {
    	if !strings.HasPrefix(u, "s3://") {
    		add("resources.s3_read_write[%d] %q must be an s3:// URI", i, u)
    	}
    }

    — taskspec.go:213–217

    That's the pattern. Inputs/Outputs should have the same check on their S3 side (whichever side that is), and it'd be worth auditing Validate once against the whole TaskSpec for other fields where "non-empty" is standing in for "actually usable" — a field that validates but can't execute is a boot's worth of money each time someone believes it.

    I'd guess that audit is a short afternoon and retires Axis A permanently, which is the difference between fixing four bugs and fixing the reason there were four.

    On this issue's own repro

    Also worth noting for whoever picks up the bash -x reproduction suggested above: #570's secondary finding is a cheaper trigger for the same instrumentation, because stage-in failure and command failure take different branches (STAGE_RC vs rc), and a bad manifest source fails before Docker is even installed. If the two paths turn out to produce the same "no record at all" symptom, that's a useful narrowing; if only one does, that localizes it.

    Filed from the scientific-codes-cookbook project. Related: #570, #571.

  4. scttfrdmn commented on Sep 5, 2026

    @scttfrdmn
    ContributorAuthor

    Fixed by #567, shipped in v0.104.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions