Skip to content

Retry transient Forbidden errors on ephemeral runner pod creation - #4711

Closed
fedor-rubalskiy wants to merge 1 commit into
actions:masterfrom
fedor-rubalskiy:retry-transient-forbidden-pod-create
Closed

fedor-rubalskiy wants to merge 1 commit into
actions:masterfrom
fedor-rubalskiy:retry-transient-forbidden-pod-create

Conversation

@fedor-rubalskiy

@fedor-rubalskiy fedor-rubalskiy commented Oct 13, 2026 •

Copy link
Copy Markdown

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/2 ENHANCE_YOUR_CALM. When a runner pod create lands in that window, the API server answers 403:

pods "arc-medium-bscbt-runner-mrf9p" is forbidden: rpc error: code = ResourceExhausted desc = stream terminated by RST_STREAM with error code: ENHANCE_YOUR_CALM

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, the IsForbidden branch only retries when the message contains exceeded quota: (#4305). Any other Forbidden goes to markAsFailed(..., 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 code ResourceExhausted, Unavailable or DeadlineExceeded. 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:

  • runner younger than 10 minutes: requeue after 30s and try to create the pod again
  • runner older than 10 minutes: delete the EphemeralRunner so the set re-creates it

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 invalid covers that). Those still go to markAsFailed.

Testing

TestReconcileForbiddenPodCreation is new, in ephemeralrunner_forbidden_test.go. It uses the fake client with an interceptor that makes pod creation return Forbidden, like the other ephemeralrunner_*_test.go files. The envtest API server cannot produce this error. Cases:

  • throttled and unavailable backend on a young runner: requeue after 30s, runner not Failed, not deleted
  • throttled backend on a runner past 10 minutes: runner deleted
  • quota exceeded, young and past 10 minutes: same two outcomes (this path had no test before)
  • missing PriorityClass (young and past 10 minutes) and a PermissionDenied gRPC status (young): runner Failed with reason InvalidPod

With the isTransientForbidden match 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 vet and gofmt are clean, and golangci-lint v2.13.2 (the version in go.yaml, run from the golangci/golangci-lint:v2.13.2 image) reports 0 issues on ./controllers/actions.github.com/....

🤖 Generated with Claude Code

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

Copy link
Copy Markdown
Author

Closing in favor of #4712, which describes the bug.

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