actions / actions-runner-controller

Kubernetes controller for GitHub Actions self-hosted runners
Apache License 2.0
4.42k stars 1.04k forks source link

Fix overscaling when the controller is much faster then the listener #3371

Closed nikola-jokic closed 3 months ago

nikola-jokic commented 3 months ago

When the ephemeral runner finishes, the listener issues a scale-down patch to the ephemeral runner set. But if ephemeral runner set reacts quicker than the listener, it may re-create the ephemeral runner, and quickly remove it. To avoid this problem, this PR introduces the following changes:

  1. Ephemeral runner cleans up its resources as soon as it is done
  2. Ephemeral runner set keeps finished ephemeral runners until the next patch request is received.
  3. The target count is calculated only on patch ID difference (or patchID == 0), i.e. when the listener patches the ephemeral runner set.
  4. The listener issues a patch request when there is a change in the state, or in case it gets notified that the job is done.

This change also requires a change in the CRD.