From f961605a519dfad80a36a1714fa0bfb11eab4026 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=A5=96=E5=BB=BA?= Date: Mon, 5 Sep 2022 13:18:43 +0800 Subject: [PATCH] fix duplicate logs for leader election (#1886) --- pkg/controller/election.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/controller/election.go b/pkg/controller/election.go index 3c3e402bfa5..2ed0631ddd6 100644 --- a/pkg/controller/election.go +++ b/pkg/controller/election.go @@ -44,13 +44,17 @@ func (c *Controller) leaderElection() { PodName: c.config.PodName, PodNamespace: c.config.PodNamespace, } - c.elector = setupLeaderElection(config) + + var flag bool for { if c.isLeader() { return } - klog.Info("waiting for becoming a leader") + if !flag { + klog.Info("waiting for becoming a leader") + flag = true + } time.Sleep(5 * time.Second) } }