Skip to content

fix(pacing): bypass informer cache in PullSlots to enforce global cap correctly - #123

Merged
Breee merged 3 commits into
mainfrom
copilot/fix-e2e-failure
Aug 3, 2026
Merged

fix(pacing): bypass informer cache in PullSlots to enforce global cap correctly#123
Breee merged 3 commits into
mainfrom
copilot/fix-e2e-failure

Conversation

Copilot AI commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

The maxConcurrentPulls global cap could be exceeded when two CachedImages sharing a PullPolicy were reconciled back-to-back. The pacing engine read pod counts from the informer cache, which lagged behind reality — so the second reconcile saw 0 active pods and created a pod despite one already existing, violating the cap.

Changes

  • internal/pacing/engine.go: Replace Engine.Client client.Client with Engine.Reader client.Reader. Pod listing now goes through this reader, which must bypass the informer cache.
  • cmd/main.go: Wire mgr.GetAPIReader() (direct API server reads, no cache) instead of mgr.GetClient() when constructing the pacing engine.
// Before
PacingEngine: pacing.NewEngine(mgr.GetClient(), podNamespace),

// After — reads directly from the API server, not the stale informer cache
PacingEngine: pacing.NewEngine(mgr.GetAPIReader(), podNamespace),

The client.Reader interface is a subset of client.Client, so no call sites beyond the constructor change.

Copilot AI added 2 commits August 3, 2026 07:14
…bal cap

The pacing engine was using the informer-cache-backed client to list active
pull Pods. This caused a TOCTOU race: when two CachedImage reconciles ran
back-to-back, the second reconcile could read a stale cache that didn't yet
reflect the pod just created by the first reconcile, causing both to launch
pods and exceed the maxConcurrentPulls global cap.

Fix by switching the Engine's reader to client.Reader (backed by
mgr.GetAPIReader()), which reads directly from the API server and always
returns an up-to-date view of active pods.
Copilot AI changed the title [WIP] Fix failing GitHub Actions job e2e fix(pacing): bypass informer cache in PullSlots to enforce global cap correctly Aug 3, 2026
Copilot AI requested a review from Breee August 3, 2026 07:18
@Breee
Breee marked this pull request as ready for review August 3, 2026 09:05
@Breee
Breee merged commit bca269c into main Aug 3, 2026
9 checks passed
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.

2 participants