Repository navigation
Prevent duplicate runner creates from stale informer lists - #4744
nikola-jokic wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
A critical cache-expiry bug can leave deleted runners counted indefinitely because unseen creates schedule no reconciliation wakeup, potentially blocking replacement, finalization, and revision cleanup.
1 open issue
What changed in this PR
This PR addresses duplicate runner creation caused by stale informer lists (#4734). It tracks successful creates locally and counts unobserved runners toward capacity without blocking increased demand or changing CRDs.
Changes:
- Adds per-set creation tracking with 60-second expiry and parent-identity isolation.
- Integrates tracking into scaling, cleanup, and manager shutdown.
- Adds stale-cache regression coverage and a shared-lease leader-handoff test.
| File | Description |
|---|---|
main.go |
Registers creation-cache cleanup on manager shutdown. |
controllers/actions.github.com/runner_creation_cache.go |
Tracks successful creates until observation or expiry. |
controllers/actions.github.com/runner_cache_test.go |
Tests stale snapshots, expiry, cleanup, concurrency, and partial failures. |
controllers/actions.github.com/runner_cache_api_test.go |
Tests interrupted-batch recovery during leader handoff. |
controllers/actions.github.com/ephemeralrunnerset_controller.go |
Accounts for unseen creates in scaling and cleanup decisions. |
controllers/actions.github.com/ephemeralrunnerset_controller_test.go |
Waits for cached busy-runner status before testing cleanup. |
Review effort: Balanced
| for uid, expiresAt := range cached.runners { | ||
| if !now.Before(expiresAt) { | ||
| delete(cached.runners, uid) | ||
| expired++ | ||
| } |
Okabe-Junya
left a comment
There was a problem hiding this comment.
Hi, let me jump in this PR :)
I think this is the read-your-own-writes gap - well-known issue of the k8s cached client - which controller-runtime v0.25 addresses with the experimental EnableReadYourWritesConsistency
(kube-controller-manager took the same approach in KEP-5647 cf. https://www.kubernetes.dev/resources/keps/5647/) I think we would consider using this.
It should also cover deletes (the scale-down half of #4734) and other cached reads, e.g. Secrets if #3825 lands. If its multi-namespace limitation is the blocker (--watch-single-namespace caches two namespaces), I'd appreciated if you noted it in the PR description (or in-tree), since it then constrains any cached read in that mode.
|
Hey @Okabe-Junya I will revisit this again before the release. There is no need to keep the PR open for now. |

Track successful runner creates in a per-set cache until observed by the informer or expired after 60 seconds. Count unseen creates toward capacity without blocking new demand or adding polling.
Includes stale-cache regression coverage and leader-handoff tests. No CRD changes.
Fixes #4722
Fixes #4734