Skip to content

Commit

Permalink
fix duplicate logs for leader election (#1886)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzujian committed Sep 5, 2022
1 parent 7ae439b commit ceb3855
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/controller/election.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,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)
}
}
Expand Down

0 comments on commit ceb3855

Please sign in to comment.