Repository navigation
Description
Describe the bug
When the runner receives a shutdown signal while a step inside a composite action is running, and that composite action has another step after it, the job ends cancelled. Since #1792, a runner shutdown ends the job failed, and it still does for a plain run step and for the last step of a composite action.
A cancelled job looks the same as one a person cancelled. On self-hosted runners that are stopped by a node shutdown, a pod eviction or a spot reclaim, tooling that reruns jobs lost to the runner cannot tell these jobs apart from intentional cancellations.
To Reproduce
Repository: https://github.com/Akais24/runner-composite-shutdown-repro (GitHub-hosted runners only)
- Each job runs a step that sends SIGTERM to
Runner.Listener15 seconds in, while the step is still insleep 300. - The same step runs in three places: a plain
runstep, the last step of a composite action, and a composite step with another step after it. - Run the
reproworkflow and compare the job conclusions.
Expected behavior
All three jobs end failure, as a runner shutdown does for a plain step.
Runner Version and Platform
2.338.2, ubuntu-latest (GitHub-hosted). Also seen on 2.337.0, Linux, self-hosted ephemeral runners.
What's not working?
Two runs gave the same result: 45765619032 and 45765789878.
| Job | Where the stopped step runs | Conclusion |
|---|---|---|
plain-step |
plain run step |
failure |
composite-last-step |
last step of a composite action | failure |
composite-step-with-next-step |
composite step with another step after it | cancelled |
Job Log Output
From composite-step-with-next-step:
##[error]The runner has received a shutdown signal. This can happen when the runner service is stopped, or a manually started runner is canceled.
##[error]The operation was canceled.
##[end-action id=__self.__run;outcome=cancelled;conclusion=cancelled;duration_ms=27587]
##[start-action display=Run echo "next step";id=__self.__run_2]
##[end-action id=__self.__run_2;outcome=skipped;conclusion=skipped;duration_ms=0]
Runner and Worker's Diagnostic Logs
On a self-hosted runner, the worker log shows the composite handler setting the result:
Update job result with current composite step result 'Canceled'.
Cause
#1792 made StepsRunner choose the result from the shutdown token (StepsRunner.cs#L152-L154):
jobContext.Result = HostContext.RunnerShutdownToken.IsCancellationRequested
? TaskResult.Failed
: TaskResult.Canceled;CompositeActionHandler still sets Canceled unconditionally in two places:
- the job cancellation callback for each composite step (CompositeActionHandler.cs#L338-L343);
- the branch for a composite step that starts after the job was already cancelled (CompositeActionHandler.cs#L376-L383).
The second place runs for the step after the stopped one and overwrites the result with Canceled. Applying the same RunnerShutdownToken check in both places should make composite actions match plain steps. I can open a PR with this change and an L0 test if that helps.
I used an AI assistant to analyze the code, build the reproduction and write this report. The results above come from the linked runs.
Activity