diff --git a/cmd/main.go b/cmd/main.go index 000feb9..655a415 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -28,7 +28,7 @@ const ( unassignTimeout = 5 * time.Minute kubeipLockName = "kubeip-lock" defaultLeaseDuration = 5 - loopInterval = 250 * time.Millisecond + pauseInterval = 3 * time.Second ) var ( @@ -179,10 +179,6 @@ func run(c context.Context, log *logrus.Entry, cfg *config.Config) error { } }() - // Create a ticker for non-blocking delay - loopTicker := time.NewTicker(loopInterval) - defer loopTicker.Stop() - for { select { case assignErr, ok := <-errorCh: @@ -208,9 +204,8 @@ func run(c context.Context, log *logrus.Entry, cfg *config.Config) error { log.Infof("static public IP address released") } return nil - case <-loopTicker.C: - // Wait for the next tick before continuing the loop - // This case prevents high CPU usage by introducing a non-blocking delay + default: + time.Sleep(pauseInterval) } } }