Skip to content

Commit da5f6cf

Browse files
committed
garbagecollector: fix logs & comments in gc sync
Signed-off-by: haorenfsa <[email protected]>
1 parent 87ca404 commit da5f6cf

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

pkg/controller/garbagecollector/garbagecollector.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ func (gc *GarbageCollector) Run(ctx context.Context, workers int, initialSyncTim
149149
if !cache.WaitForNamedCacheSync("garbage collector", waitForStopOrTimeout(ctx.Done(), initialSyncTimeout), func() bool {
150150
return gc.dependencyGraphBuilder.IsSynced(logger)
151151
}) {
152-
logger.Info("Garbage collector: all resource monitors could not be synced, proceeding anyways")
152+
logger.Info("Garbage collector: not all resource monitors could be synced, proceeding anyways")
153153
} else {
154154
logger.Info("Garbage collector: all resource monitors have synced")
155155
}
@@ -227,14 +227,13 @@ func (gc *GarbageCollector) Sync(ctx context.Context, discoveryClient discovery.
227227
}
228228
logger.V(4).Info("resynced monitors")
229229

230-
// wait for caches to fill for a while (our sync period) before attempting to rediscover resources and retry syncing.
231-
// this protects us from deadlocks where available resources changed and one of our informer caches will never fill.
232-
// informers keep attempting to sync in the background, so retrying doesn't interrupt them.
233-
// the call to resyncMonitors on the reattempt will no-op for resources that still exist.
234-
// note that workers stay paused until we successfully resync.
235-
if !cache.WaitForNamedCacheSync("garbage collector", waitForStopOrTimeout(ctx.Done(), period), func() bool {
230+
// gc worker no longer waits for cache to be synced, but we will keep the periodical check to provide logs & metrics
231+
cacheSynced := cache.WaitForNamedCacheSync("garbage collector", waitForStopOrTimeout(ctx.Done(), period), func() bool {
236232
return gc.dependencyGraphBuilder.IsSynced(logger)
237-
}) {
233+
})
234+
if cacheSynced {
235+
logger.V(2).Info("synced garbage collector")
236+
} else {
238237
utilruntime.HandleError(fmt.Errorf("timed out waiting for dependency graph builder sync during GC sync"))
239238
metrics.GarbageCollectorResourcesSyncError.Inc()
240239
}
@@ -243,7 +242,6 @@ func (gc *GarbageCollector) Sync(ctx context.Context, discoveryClient discovery.
243242
// Monitors where the cache sync times out are still tracked here as
244243
// subsequent runs should stop them if their resources were removed.
245244
oldResources = newResources
246-
logger.V(2).Info("synced garbage collector")
247245
}, period)
248246
}
249247

0 commit comments

Comments
 (0)