Skip to content

fix(bootstrap_ec2): mark a cancelled run's commit status as an error - #36

Merged
charlielye merged 1 commit into
mainfrom
cl/cancel-commit-status
Nov 25, 2026
Merged

charlielye merged 1 commit into
mainfrom
cl/cancel-commit-status

Conversation

@charlielye

Copy link
Copy Markdown
Contributor

A cancelled run left its ci/<job> commit status pending, so the pull request showed the check as still running after the Actions run said cancelled. bootstrap_ec2's signal handler now posts error with the description "Cancelled", after it has terminated the instance. GitHub statuses have no cancelled state, and error is the closest one.

post_github_status posts in the background so it never blocks a build. It gains --wait for the handler, which is about to exit: the runner kills orphaned processes at the end of the job, and could kill the post before it is sent. The post is capped at 5 seconds, well inside the runner's 10 seconds before SIGKILL.

Writing the test turned up an older bug. The signal handlers in bootstrap_ec2 and bootstrap_ec2_multi ran under errexit, so a nonzero wait on the child they had just stopped (always 143 when the cancel lands during the instance request) ended them part-way. The instance was still terminated, by the EXIT trap, so no test noticed. But nothing after that wait ran: the status post here, and in bootstrap_ec2_multi the wait for the run's log to be written out. Both handlers now turn errexit off.

I checked every other trap handler in ci3 for the same flaw. None has it: each already sets set +e, ends risky steps with || true, or has the step that could fail as its last.

tests/cancel_test stubs curl and requires every status a cancelled run posted to finish as error. Before the fix, all five cases failed. After it, all pass, on bash 5.2 and 5.3.

A cancelled run left its commit status pending, so the pull request showed the
check as still running after the run was gone. The signal handler now posts
error, 'Cancelled', once the instance is terminated, and waits for the post:
the runner kills orphaned processes when the job ends.

The handlers in bootstrap_ec2 and bootstrap_ec2_multi ran under errexit, so a
nonzero wait on the child they had just stopped ended them part-way. The
instance was still terminated, by the EXIT trap, but nothing after that wait
ran. They now turn errexit off: every step is best effort and they end with
exit 143.
@charlielye
charlielye merged commit 6239dc9 into main Nov 25, 2026
1 check passed
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