fix(ephemeralrunner): fail runners whose image cannot be pulled #4672
In the image-pull failure path the controller deletes the pod via deleteEphemeralRunnerOrPod/deletePodAsFailed, which records EphemeralRunner.Status.Reason/Message from pod.Status.{Reason,Message}. For image pull errors the pod typically stays in PodPending with empty pod.Status fields (the details are in cs.State.Waiting), so the failure will be counted but the EphemeralRunner status won’t indicate why it failed.
<!-- ccr-overview-v2 -->
Copilot review overview
🟡 Changes recommended
The image-pull failure path currently won’t persist the waiting reason/message onto the EphemeralRunner status (it uses empty pod.Status fields for PodPending), reducing debuggability and observability of the new failure mode.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1 <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.png" alt="Medium severity" width="62" height="18" align="texttop"></picture>
<details open>
<summary><strong>Open (1)</strong></summary>
</details>
<details>
<summary><strong>What changed in this PR</strong></summary>
This PR fixes a reconciliation gap in the EphemeralRunner controller where runner pods stuck in Pending due to unpullable images would never be treated as failed, causing the EphemeralRunner to remain non-terminal and hold capacity indefinitely.
Changes:
ImagePullBackOff, ErrImagePull) and immediate handling for permanent reasons (InvalidImageName, ErrImageNeverPull).maxFailures accounting apply.| File | Description |
| ---- | ----------- |
| controllers/actions.github.com/ephemeralrunner_controller.go | Detects image-pull waiting reasons and deletes/retries pods that are stuck on unpullable images. |
| controllers/actions.github.com/ephemeralrunner_controller_test.go | Adds a unit table test for image-pull logic and an envtest validating runner failure + pod recreation on InvalidImageName. |
</details>
---
💡 <a href="/actions/actions-runner-controller/new/master?filename=.github/skills/code-review/SKILL.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add a code-review agent skill</a> or configure MCP servers for context-aware, tailored reviews. <a href="https://docs.github.com/copilot/how-tos/use-copilot-agents/request-a-code-review/use-code-review?tool=webui#mcp-servers-and-agent-skills" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn more in the docs.</a>
Good catch, fixed in b4b10d0b. You are right that the pod is still Pending on this path, so pod.Status.Reason and pod.Status.Message are both empty and the failure was being recorded with nothing to explain it.
deletePodAsFailed now falls back to the runner container's waiting state when pod.Status.Reason is empty, so the EphemeralRunner reports InvalidImageName / ImagePullBackOff and the kubelet's message. Doing it there rather than in the new branch also covers any other failure where the pod never started. The envtest case now asserts Status.Reason == "InvalidImageName" alongside the failure count and the pod re-creation.
Drafted with AI assistance and checked against the code before posting.
KR-Ravindra
Problem
A runner pod whose image cannot be pulled stays
Pendingforever and theEphemeralRunnernever fails.reconcileOwnerAndPodinspects the runner container only throughcs.State.Terminated. A container waiting onInvalidImageName,ErrImageNeverPull,ImagePullBackOfforErrImagePullnever terminates, so the reconciler keepstaking the
cs.State.Terminated == nilbranch ("runner is still running"),Status.Failuresstays empty, and thescale set keeps counting that runner as pending work. Nothing times it out, so the slot is held until someone deletes
the pod and the
EphemeralRunnerby hand.Reproduces on
masterwith a runner template pointing atghcr.io/actions/actions-runner:tag-that-does-not-exist,an invalid reference, or
imagePullPolicy: Neverwith the image absent from the node. Reported in #4654.Fix
Treat an unpullable image as a pod failure and route it through the existing failure path
(
deleteEphemeralRunnerOrPod), so it uses the same backoff andmaxFailuresaccounting as every other pod failure:the pod is recreated, and a permanently broken image walks the runner to
Failedinstead of hanging.InvalidImageNameandErrImageNeverPullcannot resolve on their own, so they count immediately.ImagePullBackOffand
ErrImagePulldo recover in practice (registry rate limits, a node that has just come up), so they only countonce the pod has been waiting longer than a 5 minute grace period.
No API or configuration change.
How tested
go test ./controllers/actions.github.com/passes (envtest,KUBEBUILDER_ASSETSfrommake setup-envtest).Two new tests:
TestImagePullFailure, a table test over the waiting reasons and the grace-period boundary.InvalidImageNameand expects a recorded failure plus a recreated pod. With the new branch disabled it fails:One open question for you: 5 minutes is a guess for the retryable reasons. Happy to make it configurable on the
controller, or to drop the grace period and only act on the two permanent reasons, whichever you prefer.
Fixes #4654
_Implementation assisted by an AI agent I operate; I reviewed the diff and ran the tests myself._