Skip to content

Count runners without the cache before an EphemeralRunnerSet scale up - #4723

Open
yaronr wants to merge 1 commit into
actions:masterfrom
yaronr:fix-ephemeralrunnerset-stale-cache-overcreate
Open

yaronr wants to merge 1 commit into
actions:masterfrom
yaronr:fix-ephemeralrunnerset-stale-cache-overcreate

Conversation

@yaronr

@yaronr yaronr commented Oct 21, 2026

Copy link
Copy Markdown

Fixes #4722

Problem

The EphemeralRunnerSet reconciler counts its runners from the informer cache (r.List with resourceOwnerKey) and records nothing about the runners it has just created. The watch event of the first runner of a scale-up batch requeues the set before the cache holds the rest of the batch. If the listener publishes a new patchID in that window, the reconcile passes the patch-ID check, sees a partial count, and creates the missing runners a second time. The set ends above Spec.Replicas, and each extra runner holds a pod (and, with a cluster autoscaler, a node) until scale down can retire it.

0.15.0 made the window wider: runners of a batch are now created in parallel, and updateStatus no longer writes a status PATCH after every create, so the reconcile returns right after the last Create response.

Fix

In the scale-up branch, count the set's runners again through APIReader and create only the real shortfall. Ownership is filtered in process, as in patchAppliedActionableRevisionStatus, because resourceOwnerKey is a cache-only index. The extra read is one namespace LIST per scale-up decision, not per reconcile. The controller logs Uncached runner count differs from the cached count when the two counts differ.

Tests

  • New TestScaleUpDoesNotRecreateRunnersMissingFromTheCache: a cache-backed client that lists only the first created runner, plus a patchID bump between two reconciles. Without the fix the set ends with 3 runners for replicas: 2; with it, 2.
  • go test -skip '^TestAPIs$' ./controllers/actions.github.com/...: ok.
  • Envtest suite (TestAPIs, 186 specs, envtest 1.37.0): ok.
  • gofmt -l and go vet on the package: clean.

Production evidence

We run this change on 0.15.0 for a CI scale set. In one run the listener published replicas: 1 and then replicas: 2 within about 2 s. The controller logged "cached": 1, "uncached": 2, "desired": 2 and created no third runner. Without the change, that reconcile would have created one.

🤖 Generated with Claude Code

The EphemeralRunnerSet reconciler counts its runners from the informer
cache and records nothing about the runners it creates. The watch event
of the first runner of a batch requeues the set before the cache holds
the others. When the listener publishes a new patch ID in that window,
the reconcile reaches the scaling block with a partial count and creates
the missing runners a second time, so the set ends above Spec.Replicas.

Before a scale up, count the set's runners again through APIReader and
create only the real shortfall. The extra read is one namespace LIST per
scale-up decision, not per reconcile.

Fixes actions#4722

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@yaronr

yaronr commented Nov 22, 2026

Copy link
Copy Markdown
Author

We hit this in production on 0.15.0 and currently carry a controller patch for it. #4723 (ours) and #4744 both target this bug, and we're happy with whichever approach the maintainers prefer. We'd rather drop our patch than get ours merged. We can share our production evidence and regression test with either PR. One thing to check on the #4744 approach: if a runner is deleted while its create is still counted as unseen, replacement could be delayed until the 60s window expires. #4704 shows replacement latency already matters. Please keep this issue open while the fix is in review.

This branch has not been deployed

No deployments
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.

EphemeralRunnerSet creates more EphemeralRunners than spec.replicas on scale up (stale cache, no create expectations)

1 participant