mirror of
https://github.com/lukaszraczylo/kubemirror.git
synced 2026-10-31 10:09:35 +00:00
perf(controller): stop per-target apiserver reads in mirror reconcile
The mirror reconcile path issued one direct apiserver GET per target namespace on every pass. With N sources and M target namespaces each resync produced N*M GET requests. On a 65-namespace cluster this generated 63 GET/s and overloaded one control-plane node. Changes: - reconcileMirror now trusts the informer cache. Content drift is detected via the source hash annotation. A stale resourceVersion makes Update return a conflict, which requeues the source. - The verify-source-freshness flag now defaults to false. The Helm chart passes the value explicitly, so the chart default of false matches the binary behaviour. - Reconcile performs one namespace LIST per pass. Target resolution and orphan cleanup share the result. - Add load regression tests that count direct API reads in the reconcile hot path.
This commit is contained in:
@@ -110,12 +110,12 @@ func main() {
|
||||
"Burst limit for API server requests.")
|
||||
flag.DurationVar(&resyncPeriod, "resync-period", 10*time.Minute,
|
||||
"Period for resyncing all resources (catches updates missed due to informer cache delays).")
|
||||
flag.BoolVar(&verifySourceFreshness, "verify-source-freshness", true,
|
||||
flag.BoolVar(&verifySourceFreshness, "verify-source-freshness", false,
|
||||
"Verify source resource freshness by comparing cache with direct API read. "+
|
||||
"Prevents mirroring stale data and missed orphan cleanups when the informer "+
|
||||
"cache lags behind watch events. Trade-off: one extra API call per reconcile "+
|
||||
"when the cache is stale. Disable only if you are confident your cluster's "+
|
||||
"watch latency is negligible.")
|
||||
"Converges a few seconds faster when the informer cache lags behind watch "+
|
||||
"events, at the cost of one direct apiserver GET per reconcile. Off by "+
|
||||
"default: a stale read self-corrects on the next watch event, and update "+
|
||||
"conflicts requeue automatically.")
|
||||
flag.BoolVar(&lazyWatcherInit, "lazy-watcher-init", false,
|
||||
"Enable lazy watcher initialization - only create informers for resource types that have resources marked for mirroring. "+
|
||||
"Significantly reduces memory usage by avoiding watchers for unused resource types. "+
|
||||
|
||||
Reference in New Issue
Block a user