Skip to content

perf(imageinventory): parallelize ImageRegistry CR upsert and orphan delete#252

Merged
golgoth31 merged 2 commits intomainfrom
perf/sync-registry-crs-parallel
May 8, 2026
Merged

perf(imageinventory): parallelize ImageRegistry CR upsert and orphan delete#252
golgoth31 merged 2 commits intomainfrom
perf/sync-registry-crs-parallel

Conversation

@golgoth31
Copy link
Copy Markdown
Owner

Summary

  • SyncRegistryCRsHandler ran one CreateOrPatch per (host, namespace) group sequentially, and each orphan delete did a redundant Get before Delete. With dozens of groups per inventory the serialized API round-trips pushed the handler beyond 5s.
  • Upserts and orphan deletes now run through an errgroup capped at 8 in-flight ops; the desired ref map is built up front from the deterministic group keys so the parallel loop has no shared writes.
  • The pre-flight Get on orphan delete is dropped — Delete already returns IsNotFound, which we treat as a no-op.

Test plan

  • go build ./...
  • make lint
  • make test (imageinventory + chain packages green)
  • Observe ReconcileDuration{controller="imageinventory",handler="*SyncRegistryCRsHandler"} drop on a real cluster

🤖 Generated with Claude Code

golgoth31 and others added 2 commits May 8, 2026 17:14
…delete

SyncRegistryCRsHandler ran one CreateOrPatch per (host, namespace) group
sequentially, and each orphan delete did a redundant Get before Delete.
With dozens of groups per inventory, the serialized API round-trips
pushed the handler beyond 5s.

Run upserts and orphan deletes through an errgroup capped at 8
in-flight ops, build the desired ref map up front from the deterministic
group keys (no shared writes inside the parallel loop), and drop the
pre-flight Get on orphan delete since IsNotFound from Delete is already
treated as a no-op.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Two follow-ups from review of the parallel sync_registry_crs handler:

- Drop context.Canceled returned by peer goroutines once errgroup cancels
  egCtx, so eg.Wait() surfaces the actual root cause (RBAC, admission
  webhook, etc.) instead of a generic "context canceled" from a sibling.
- Restore the IsNotFound short-circuit in deleteOrphans before the V(1)
  log line, so we no longer report "deleted orphan ImageRegistry" for
  CRs that were already gone.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@golgoth31 golgoth31 merged commit b691a73 into main May 8, 2026
2 checks passed
@golgoth31 golgoth31 deleted the perf/sync-registry-crs-parallel branch May 8, 2026 15:25
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.

1 participant