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