Skip to content

Commit

Permalink
fix: start informer when controller is leader
Browse files Browse the repository at this point in the history
  • Loading branch information
oilbeater committed May 15, 2019
1 parent 22da454 commit 0f9d1e4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ func (c *Controller) Run(stopCh <-chan struct{}) error {
})
c.elector = elector
for {
klog.Info("waiting for a leader")
if c.hasLeader() {
klog.Info("waiting for becoming a leader")
if c.isLeader() {
break
}
time.Sleep(1 * time.Second)
Expand Down
1 change: 1 addition & 0 deletions pkg/controller/election.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func setupLeaderElection(config *leaderElectionConfig) *leaderelection.LeaderEle
if config.OnStoppedLeading != nil {
config.OnStoppedLeading()
}
klog.Fatalf("leaderelection lost")
},
OnNewLeader: func(identity string) {
klog.Infof("new leader elected: %v", identity)
Expand Down

0 comments on commit 0f9d1e4

Please sign in to comment.