Skip to content

EphemeralRunnerSet controller creates more runners than spec.replicas when its cache lags its own creates #4734

Description

@jia-pylon

Checks

Controller Version

gha-runner-scale-set-0.14.2; also reproduced on master 89f34c4f782d

Deployment Method

Helm

Checks

  • This isn't a question or user support case (For Q&A and community support, go to Discussions).
  • I've read the Changelog before submitting this issue and I'm sure it's not due to any recently-introduced backward-incompatible changes

To Reproduce

  1. Check out master and run the controller envtest suite against any recent kube-apiserver (reproduced on 1.35.0, 1.36.2 and 1.37.0 from setup-envtest):
    KUBEBUILDER_ASSETS=... go test ./controllers/actions.github.com/ -count=1 -ginkgo.v
  2. Find a scale-up from 0 in the controller log, e.g. in It should create/add all required resources for a new EphemeralRunnerSet (finalizer).

Describe the bug

EphemeralRunnerSetReconciler.Reconcile lists child EphemeralRunners from the informer cache (MatchingFields{resourceOwnerKey: ...}) and creates desired - current runners. Nothing tracks creates or deletes that are still in flight. Its own status patch, or the add event for the first runner in a batch, can wake the next reconcile before the cache has seen the whole batch. That reconcile counts too few runners and creates another batch. It then deletes the surplus, so specs that wait for the final count still pass, but spec.replicas has been exceeded in the meantime. Scale-down has the same shape: a cache that hasn't caught up with deletes can lead to choosing more runners to delete.

Over-creates in unmodified full-suite runs on master (each run executes all 188 specs):

kube-apiserver full runs runs with an over-create in the log
1.35.0 8 6
1.36.2 8 8
1.37.0 8 7

The race sometimes surfaces as an assertion failure instead, e.g. Should replace finished ephemeral runners with new ones on 0.14.2: current: 0, desired: 2 → 2 created → status count 0 → current: 0, desired: 2 → 2 more created → 4 pending.

Describe the expected behavior

The controller never has more than spec.replicas runners because of its own stale reads, and never deletes more than the scale-down requires. kube-controller-manager's ReplicaSet controller solves the same problem with controller expectations.

Additional Context

In production, runner sets briefly over-provision runner pods. The extra runners are deleted again, but in the meantime they use node capacity.

Controller Logs

1.36.2 envtest, one namespace, all within 2026-11-04T20:23:49Z:

Scaling comparison: current=0, deleting=0, desired=5
Creating new ephemeral runners (scale up): count=5
Created new ephemeral runner  (x5, distinct names)
Scaling comparison: current=1, deleting=0, desired=5
Creating new ephemeral runners (scale up): count=4
Created new ephemeral runner  (x4, distinct names)
Scaling comparison: current=7, deleting=0, desired=5
Deleting ephemeral runners (scale down): count=2

Nine runners were created where five were desired. Full logs are available on request.

Runner Pod Logs

N/A (controller-side race)

I have a fix with regression tests ready and will open a PR that references this issue.

Activity

  1. github-actions commented on Nov 4, 2026

    @github-actions
    Contributor

    Hello! Thank you for filing an issue.

    The maintainers will triage your issue shortly.

    In the meantime, please take a look at the troubleshooting guide for bug reports.

    If this is a feature request, please review our contribution guidelines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions