Skip to content

Commit

Permalink
topology-gc: move initial GC out of startNodeInformer()
Browse files Browse the repository at this point in the history
Small refactor. Contextually this feels more like under periodicGC().
  • Loading branch information
marquiz committed Aug 21, 2023
1 parent 0b5e51b commit e5025b6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/nfd-topology-gc/nfd-nrt-gc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -172,8 +175,6 @@ func (n *topologyGC) startNodeInformer() error {
n.factory.Start(n.stopChan)
n.factory.WaitForCacheSync(n.stopChan)

n.garbageCollect()

return nil
}

Expand Down

0 comments on commit e5025b6

Please sign in to comment.