ci(run_command): allow --failed rerun to reuse EC2 on first-attempt failure#1179
Closed
yokofly wants to merge 1 commit into
Closed
ci(run_command): allow --failed rerun to reuse EC2 on first-attempt failure#1179yokofly wants to merge 1 commit into
yokofly wants to merge 1 commit into
Conversation
…ailure
`gh run rerun --failed` re-runs failed and skipped jobs but never re-runs
already-successful upstream jobs. In `run_command.yml`, `start-runner`
succeeds and `stop-runner` previously ran with `if: ${{ always() }}`, so
on first failure the EC2 was terminated even when the user planned to
rerun. The re-queued `execute-command` then waited forever for the
already-deregistered runner label.
Skip `stop-runner` on first-attempt `execute-command` failure so the EC2
(and its runner registration) survives long enough for `--failed` rerun
to land on the same machine. Subsequent attempts (`run_attempt > 1`)
always terminate, so a second failure does not leak the instance.
Add a step-summary notice on first-attempt failure pointing the next
reader at the rerun behavior and at the manual `terminate-instances`
fallback if no rerun is planned.
Caveat for review: this assumes the ec2-github-runner agent is not
registered with `--ephemeral`. If it is, the agent exits after the
first job regardless of EC2 lifetime, and `--failed` rerun would still
hang — in that case we also need to disable ephemeral mode or restart
the agent on rerun. Worth confirming against the AMI / fork before
merging.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.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.
Summary
stop-runner.iffromalways()tosuccess() || cancelled() || github.run_attempt > 1. On a first-attemptexecute-commandfailure the EC2 is left alive sogh run rerun --failedcan land on the same machine.aws ec2 terminate-instancesfallback for users who do not plan to rerun.Motivation
The release build run #26276953469 failed in
Build_Linux_Arm64 / Execute Commandwith a transientunknown bloberror duringdocker push ghcr.io/timeplus-io/proton:${SHA}_arm64v8. Build, Docker Hub push, and most of the GHCR push had already succeeded — only the final GHCR layer push failed.gh run rerun --failedwas the natural next step, but it produced a hang on attempt 2:start-runner(succeeded on attempt 1) was not re-executedstop-runner(succeeded on attempt 1 because ofif: always()) had already terminated the EC2 and deregistered the runnerexecute-command(attempt 2) queued indefinitely waiting for a runner label that no longer maps to a live machineGitHub Actions
--failedrerun semantics intentionally skip already-successful upstream jobs and reuse their outputs. With ephemeral self-hosted runners that is a footgun: outputs are durable, EC2 instances are not.Behavior table
success()true)--failedreruncancelled()true)run_attempt > 1true)Trade-off: a terminal first-attempt failure with no rerun leaks the EC2 until manual cleanup or a sweeper runs. The step-summary notice surfaces this with a copy-pasteable
terminate-instancescommand.Caveat for review
This assumes the
yokofly/ec2-github-runneragent is not registered with--ephemeral. If it is, the runner agent exits after the first job regardless of EC2 lifetime, so keeping the instance alive still leaves no runner to pick up the re-queuedexecute-command. In that case--failedrerun would still hang and the right fix is also to disable ephemeral mode on the start side (or restart the agent on rerun).Worth confirming against the pinned fork (
522cb941f0d76565385ce7aeb6771bf58451ba1b) and AMI bootstrap before merge.Test plan
python3 -c 'yaml.safe_load(...)')gh run rerun --failedlands on the same EC2 and succeedsBuild_Linux_*job🤖 Generated with Claude Code