Repository navigation
Retry transient Forbidden errors on ephemeral runner pod creation - #4711
Closed
fedor-rubalskiy wants to merge 1 commit into
Closed
fedor-rubalskiy wants to merge 1 commit into
fedor-rubalskiy wants to merge 1 commit into
Conversation
When the API server fails a backend call while admitting a runner pod, it answers 403 with the gRPC status in the message, for example "pods ... is forbidden: rpc error: code = ResourceExhausted desc = stream terminated by RST_STREAM with error code: ENHANCE_YOUR_CALM". The IsForbidden branch only retried "exceeded quota:". Any other Forbidden marked the EphemeralRunner Failed on the first attempt. A Failed runner is counted by scaleTotal() and is not removed until the set is cleaned up, so it keeps a replica slot and the queued job gets no runner. Treat a Forbidden message carrying a ResourceExhausted, Unavailable or DeadlineExceeded gRPC status like the quota case: requeue after 30s while the runner is younger than 10 minutes, then delete it so it is re-created. Other Forbidden errors still mark the runner Failed. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
fedor-rubalskiy
requested review from
a team,
Steve-Glass,
mumoshu,
nikola-jokic,
rentziass and
toast-gear
as code owners
October 13, 2026 17:39
Author
|
Closing in favor of #4712, which describes the bug. |
This was referenced Oct 14, 2026
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.
When the API server rejects a runner pod with a Forbidden that comes from a failed backend call, the controller marks the EphemeralRunner Failed on the first attempt. The runner keeps its slot in the EphemeralRunnerSet, so the queued job gets no runner until someone deletes the EphemeralRunner by hand.
We hit this on GKE. The control plane briefly throttles every client with gRPC
ResourceExhausted/ HTTP/2ENHANCE_YOUR_CALM. When a runner pod create lands in that window, the API server answers 403:It happened three times in four days, and one job sat queued for about 17 hours. Argo CD, istiod and the kubelets logged the same throttling at the same moments, and the pod spec was fine.
In
EphemeralRunnerReconciler.Reconcile, theIsForbiddenbranch only retries when the message containsexceeded quota:(#4305). Any other Forbidden goes tomarkAsFailed(..., ReasonInvalidPodFailure).ephemeralRunnersByState.scaleTotal()counts failed runners (pending + running + failed) and nothing deletes them until the set is cleaned up, so the slot stays taken. That is the symptom in #3685. In #4258 a maintainer said a runner should only end up Failed when the pod definition is wrong and should otherwise be retried. A throttled API server does not fit that.This adds
isTransientForbidden, which matches a Forbidden message carrying a gRPC status with codeResourceExhausted,UnavailableorDeadlineExceeded. Such a message means a backend of the API server failed, not that the pod was rejected. These errors now follow the two paths the quota error already has:After the window the runner is deleted rather than marked Failed, as in the quota case. Marking it Failed after 10 minutes of throttling would leave the stuck slot this change is meant to remove.
The API server returns these as a plain Forbidden with no structured cause, so the only thing to go on is the message, as with
exceeded quota:. I did not retry every Forbidden. A pod that references a missing PriorityClass or fails admission is also Forbidden and has to keep failing fast (It should failed if a pod template is invalidcovers that). Those still go tomarkAsFailed.Testing
TestReconcileForbiddenPodCreationis new, inephemeralrunner_forbidden_test.go. It uses the fake client with an interceptor that makes pod creation return Forbidden, like the otherephemeralrunner_*_test.gofiles. The envtest API server cannot produce this error. Cases:PermissionDeniedgRPC status (young): runner Failed with reasonInvalidPodWith the
isTransientForbiddenmatch disabled, the three transient cases fail.Ran
go test -short ./controllers/actions.github.com/...against envtest (Kubernetes 1.37) with go 1.27.2. It passes, including the existing Ginkgo specs.go vetandgofmtare clean, andgolangci-lintv2.13.2 (the version ingo.yaml, run from thegolangci/golangci-lint:v2.13.2image) reports 0 issues on./controllers/actions.github.com/....🤖 Generated with Claude Code