perf(imageinventory): parallelize ImageRegistry CR upsert and orphan delete#252
Merged
perf(imageinventory): parallelize ImageRegistry CR upsert and orphan delete#252
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SyncRegistryCRsHandlerran oneCreateOrPatchper(host, namespace)group sequentially, and each orphan delete did a redundantGetbeforeDelete. With dozens of groups per inventory the serialized API round-trips pushed the handler beyond 5s.errgroupcapped 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.Geton orphan delete is dropped —Deletealready returnsIsNotFound, which we treat as a no-op.Test plan
go build ./...make lintmake test(imageinventory + chain packages green)ReconcileDuration{controller="imageinventory",handler="*SyncRegistryCRsHandler"}drop on a real cluster🤖 Generated with Claude Code