fix(runners): preserve stopped status when Run returns after termination#3977
Draft
cursor[bot] wants to merge 1 commit into
Draft
fix(runners): preserve stopped status when Run returns after termination#3977cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
Commit 2a156b3 moved the post-Run IsFinished early return into the success-only branch. When applyTerminatedJobs (or a server-side stop) already marked a job stopped and Run returned an error from the killed process, completeAfterRun overwrote stopped with failed. Restore the finished/killed guards on the error path and add regression tests. Co-authored-by: Denis Gukov <fiftin@outlook.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug and impact
When the server tells a runner to emergency-stop a task (
terminated_jobsfrom progress sync, or a stop while the job is running),applyTerminatedJobscorrectly sets the job status to stopped and kills the process. IfExecutor.Runthen returns an error from the interrupted process, the runner's post-Run handler overwrote stopped with failed.User-facing impact: Force-stopped or reassigned tasks were reported back to the server as failed instead of stopped, triggering wrong alerts, workflow edges, and task history.
Root cause
Commit
2a156b30(fix(runners): logs) moved theIsFinished()early return from before the error handler into the success-only branch. On the error path, any non-stoppingstatus — including already-stopped— was downgraded tofailed.Fix and validation
completeAfterRunwith the same guards used server-side (IsFinished,IsKilled,stopping→stopped).go test ./services/runners/ -run TestRunningJob_completeAfterRun -v -count=1