Skip to content

Commit

Permalink
Merge pull request #1661 from Icarus9913/fix/wk/ip-gc
Browse files Browse the repository at this point in the history
fix IP gc
  • Loading branch information
iiiceoo authored Apr 14, 2023
2 parents af8d618 + 228c40f commit 03f7c90
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/gcmanager/pod_informer.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@ func (s *SpiderGC) startPodInformer(ctx context.Context) {
s.informerFactory = informerFactory
informerFactory.Start(innerCtx.Done())

// Let the leader trigger IP GC scan all.
// When the spiderpool-controller restarted, it will trigger IP GC scan all first.
// If the pod informer not starts and the user delete some pods, this will lead to IP leakage.
logger.Debug("try to trigger scan all with leader elected")
cacheSync := cache.WaitForCacheSync(innerCtx.Done())
if !cacheSync {
innerCancel()
continue
}
s.gcSignal <- struct{}{}

<-innerCtx.Done()
logger.Error("k8s pod informer broken")
}
Expand Down

0 comments on commit 03f7c90

Please # to comment.