Skip to content

fix(pod): restore --stop-after and --terminate-after, validated - #331

Draft
justinwlin wants to merge 2 commits into
mainfrom
justinlin/con-1258-client-validate-schedule-flags
Draft

fix(pod): restore --stop-after and --terminate-after, validated#331
justinwlin wants to merge 2 commits into
mainfrom
justinlin/con-1258-client-validate-schedule-flags

Conversation

@justinwlin

@justinwlin justinwlin commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Brings back --stop-after and --terminate-after, removed in #330, with every client-side way of losing the deadline closed.

Do not merge until the API enforces the timer. Until then #330's removal is the correct behaviour, and this PR would put the silent-billing failure straight back. Stacked on #330.

What this fixes

Problem Fix
Docs advertise 1h, 24h, 7d; the GraphQL DateTime scalar rejects them duration.ParseDeadline resolves durations against the clock and sends RFC 3339
Raw GraphQL scalar error leaked to the user Rejected locally, before the create call, so a bad value never costs a billed pod
Past timestamps accepted, deadline never arrives Rejected, with the current time in the message
CPU pods accept the flag and silently drop it (REST v2 has no scheduling field) Errors instead
No confirmation the timer was applied Resolved deadline echoed to stderr
$ runpodctl pod create --gpu-id "NVIDIA RTX 4000 Ada Generation" --image ubuntu:22.04 --stop-after 4m
note: auto-stop scheduled for 2026-08-26T16:48:35Z
{ "id": "bdwcl5lzqwqny0", ... }

What it does not fix

Whether the pod actually stops. stopAfter / terminateAfter are write-only from a client: valid input on PodFindAndDeployOnDemandInput, not readable on the Pod type, absent from REST v2. The CLI cannot verify the deadline landed, so the stderr note describes what was sent, not what will happen. Enforcement is an API-side change.

Verification

Live against production:

$ runpodctl pod create --compute-type CPU --image ubuntu:22.04 --stop-after 2h
{"error":"--stop-after is not supported for compute type CPU; ...","code":"cli_error"}

$ runpodctl pod create --gpu-id "NVIDIA A40" --image ubuntu:22.04 --stop-after "1h ago"
{"error":"invalid --stop-after: invalid time \"1h ago\": use a duration like 2h, 7d or an rfc3339 timestamp ...","code":"cli_error"}

$ runpodctl pod create --gpu-id "NVIDIA A40" --image ubuntu:22.04 --terminate-after "2020-01-01T00:00:00Z"
{"error":"invalid --terminate-after: ... must be in the future (now is 2026-08-26T16:44:26Z)","code":"cli_error"}

Unit tests: TestResolvePodSchedule, TestResolvePodScheduleNotesTheDeadline, TestParseDeadline. go test ./... green.

Both flags were forwarded to podFindAndDeployOnDemand, which accepts
stopAfter/terminateAfter and never acts on them: the pod keeps running,
and billing, past the deadline. The value is also not readable back from
the Pod type or REST v2, so the cli cannot detect the failure after the
fact either.

Nothing a client can do makes the timer fire, and a flag that silently
costs money is worse than no flag, so both are gone. Passing one is now
a usage error.

Also drops StopAfter/TerminateAfter from CreatePodGQLInput and
duration.ParseDeadline, which had no other caller.
@justinwlin
justinwlin force-pushed the justinlin/con-1258-enforce-runpodctl-stop-after-and-terminate-after-timers branch from 9c44819 to d381563 Compare August 26, 2026 19:28
Brings back the two flags with every client-side way of losing the
deadline closed. Merge only once the api enforces stopAfter and
terminateAfter; until then their removal is the correct behaviour.

- duration.ParseDeadline accepts a duration (2h, 7d) or an rfc3339 time
  and rejects the past, so the documented duration form works instead of
  hitting the graphql DateTime scalar.
- Both flags resolve before the create call, so a bad value never costs
  a billed pod.
- CPU pods error rather than dropping the flag: they are created over
  rest v2, which has no scheduling field.
- The resolved deadline is echoed to stderr, since neither the create
  response nor a pod read exposes it.
@justinwlin
justinwlin force-pushed the justinlin/con-1258-client-validate-schedule-flags branch from 6231272 to 9188ca5 Compare August 26, 2026 19:29
Base automatically changed from justinlin/con-1258-enforce-runpodctl-stop-after-and-terminate-after-timers to main August 27, 2026 22:51
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.

1 participant