From f05b0e26ea2911cf377cd3ddf7f5a3f445167225 Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Thu, 17 Aug 2023 17:58:16 +0300 Subject: [PATCH] topology-gc: move initial GC out of startNodeInformer() Small refactor. Contextually this feels more like under periodicGC(). --- pkg/nfd-topology-gc/nfd-nrt-gc.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/nfd-topology-gc/nfd-nrt-gc.go b/pkg/nfd-topology-gc/nfd-nrt-gc.go index d460db2c4..d5dfafd95 100644 --- a/pkg/nfd-topology-gc/nfd-nrt-gc.go +++ b/pkg/nfd-topology-gc/nfd-nrt-gc.go @@ -146,6 +146,9 @@ func (n *topologyGC) garbageCollect() { // periodicGC runs garbage collector at every gcPeriod to make sure we haven't missed any node func (n *topologyGC) periodicGC(gcPeriod time.Duration) { + // Do initial round of garbage collection at startup time + n.garbageCollect() + gcTrigger := time.NewTicker(gcPeriod) defer gcTrigger.Stop() for { @@ -172,8 +175,6 @@ func (n *topologyGC) startNodeInformer() error { n.factory.Start(n.stopChan) n.factory.WaitForCacheSync(n.stopChan) - n.garbageCollect() - return nil }