Skip to content

feat(run-task): send SIGTERM to the task's processes shortly before maxRunTime - #1084

Open
benoitgoupilleau wants to merge 1 commit into
taskcluster:mainfrom
benoitgoupilleau:run-task-max-run-time-abort
Open

benoitgoupilleau wants to merge 1 commit into
taskcluster:mainfrom
benoitgoupilleau:run-task-max-run-time-abort

Conversation

@benoitgoupilleau

Copy link
Copy Markdown

When a task exceeds its maxRunTime, the worker kills its processes straight away, so test harnesses can't log that they were aborted and their structured logs just stop.

This makes run-task abort the task itself shortly before the deadline:

  • The task transform passes maxRunTime to the task in the TASKCLUSTER_MAX_RUN_TIME environment variable, for both docker-worker and generic-worker payloads.
  • On POSIX, run-task schedules an abort at maxRunTime minus 5%, capped at 60 seconds early. It sends SIGTERM to its process group (run-task is PID 1 under docker-worker/d2g and the group leader under generic-worker), or to its direct child if it is not the group leader.
  • A SIGTERM received while a command runs is deferred until the command exits, so run-task keeps forwarding the task's output while the harness shuts down.
  • After an abort, run-task exits with a failure code (128 + signal if the child died from a signal) and prints a line saying the task was aborted for exceeding its maxRunTime.

The worker's own kill at maxRunTime is unchanged and remains the backstop if the task's processes ignore SIGTERM. Nothing changes on Windows, and tasks without TASKCLUSTER_MAX_RUN_TIME in their environment behave as before.

This is the upstream counterpart of the gecko change in https://bugzilla.mozilla.org/show_bug.cgi?id=2082559 (D338003), needed by the gecko tasks that run the upstream run-task as run-task-git.

Tests cover the margin calculation, invalid values, both signalling paths, a real child that receives SIGTERM while its output keeps flowing, the exit code mapping, and the transform for both worker implementations.

@benoitgoupilleau
benoitgoupilleau requested a review from a team as a code owner October 30, 2026 11:26
…axRunTime

When a task exceeds its maxRunTime, the worker kills its processes straight
away, so test harnesses can't log that they were aborted, and their
structured logs just stop.

run-task now aborts the task itself, 5% of maxRunTime early and at most 60
seconds early: it sends SIGTERM to its process group, keeps forwarding the
output of its command until it exits, and then fails the task. The task
transform passes maxRunTime to run-task in the TASKCLUSTER_MAX_RUN_TIME
environment variable, for both docker-worker and generic-worker. The
worker's own kill is unchanged, and still happens if the task's processes
ignore SIGTERM. Nothing changes on Windows.

This is the upstream counterpart of the gecko change in
https://bugzilla.mozilla.org/show_bug.cgi?id=2082559, needed by the gecko
tasks that run the upstream run-task as run-task-git.
@benoitgoupilleau
benoitgoupilleau force-pushed the run-task-max-run-time-abort branch from 544a30a to 77add46 Compare October 30, 2026 14:35

This branch has not been deployed

No deployments
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