File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -91,9 +91,10 @@ type controllerManager struct {
91
91
// metricsListener is used to serve prometheus metrics
92
92
metricsListener net.Listener
93
93
94
- mu sync.Mutex
95
- started bool
96
- errChan chan error
94
+ mu sync.Mutex
95
+ started bool
96
+ startedLeader bool
97
+ errChan chan error
97
98
98
99
// internalStop is the stop channel *actually* used by everything involved
99
100
// with the manager as a stop channel, so that we can pass a stop channel
@@ -135,14 +136,18 @@ func (cm *controllerManager) Add(r Runnable) error {
135
136
return err
136
137
}
137
138
139
+ var shouldStart bool
140
+
138
141
// Add the runnable to the leader election or the non-leaderelection list
139
142
if leRunnable , ok := r .(LeaderElectionRunnable ); ok && ! leRunnable .NeedLeaderElection () {
143
+ shouldStart = cm .started
140
144
cm .nonLeaderElectionRunnables = append (cm .nonLeaderElectionRunnables , r )
141
145
} else {
146
+ shouldStart = cm .startedLeader
142
147
cm .leaderElectionRunnables = append (cm .leaderElectionRunnables , r )
143
148
}
144
149
145
- if cm . started {
150
+ if shouldStart {
146
151
// If already started, start the controller
147
152
go func () {
148
153
cm .errChan <- r .Start (cm .internalStop )
@@ -316,6 +321,8 @@ func (cm *controllerManager) startLeaderElectionRunnables() {
316
321
cm .errChan <- ctrl .Start (cm .internalStop )
317
322
}()
318
323
}
324
+
325
+ cm .startedLeader = true
319
326
}
320
327
321
328
func (cm * controllerManager ) waitForCache () {
You can’t perform that action at this time.
0 commit comments