Skip to content

Enforce max_duration on the server - #4273

Open
un-def wants to merge 1 commit into
masterfrom
issue_4259_max_duration_server_enforcement
Open

Enforce max_duration on the server#4273
un-def wants to merge 1 commit into
masterfrom
issue_4259_max_duration_server_enforcement

Conversation

@un-def

@un-def un-def commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

Previously, max_duration was enforced only by the runner, which cancels the job context once the deadline passes. When that failed to stop the workload, nothing else did: a RUNNING job has no server-side liveness bound, and the runner keeps answering /api/pull with the job still running.

Now the server enforces the deadline as well, without depending on the runner being healthy. JobModel.running_at records when the job entered RUNNING, and a job still running that long plus max_duration and MAX_DURATION_ENFORCEMENT_GRACE is terminated with MAX_DURATION_EXCEEDED.

The grace period keeps the runner primary, since it stops the job gracefully and reports a more accurate state, and lets the server act only when the runner did not.

Jobs whose running_at is unset -- those already running when the server is upgraded -- are left to the runner.

Fixes: #4259

Previously, `max_duration` was enforced only by the runner, which
cancels the job context once the deadline passes. When that failed to
stop the workload, nothing else did: a RUNNING job has no server-side
liveness bound, and the runner keeps answering `/api/pull` with the
job still running.

Now the server enforces the deadline as well, without depending on the
runner being healthy. `JobModel.running_at` records when the job
entered RUNNING, and a job still running that long plus `max_duration`
and `MAX_DURATION_ENFORCEMENT_GRACE` is terminated with
`MAX_DURATION_EXCEEDED`.

The grace period keeps the runner primary, since it stops the job
gracefully and reports a more accurate state, and lets the server act
only when the runner did not.

Jobs whose `running_at` is unset -- those already running when the
server is upgraded -- are left to the runner.

Fixes: #4259
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.

[Bug]: max_duration signals the wrapper shell, not the job (workload survives and the runner never reports the timeout)

1 participant