File tree Expand file tree Collapse file tree 1 file changed +10
-18
lines changed Expand file tree Collapse file tree 1 file changed +10
-18
lines changed Original file line number Diff line number Diff line change @@ -161,16 +161,14 @@ func (cm *controllerManager) GetRESTMapper() meta.RESTMapper {
161
161
}
162
162
163
163
func (cm * controllerManager ) Start (stop <- chan struct {}) error {
164
- if cm .resourceLock == nil {
165
- // join the passed-in stop channel as an upstream feeding into cm.stopper
166
- go func () {
167
- <- stop
168
- close (cm .stopper )
169
- }()
164
+ defer close (cm .stopper )
170
165
166
+ if cm .resourceLock == nil {
171
167
go cm .start ()
172
168
select {
173
- case <- cm .stop :
169
+ // Only this function should receive from stop, and everything else
170
+ // should receive from cm.stop.
171
+ case <- stop :
174
172
// we are done
175
173
return nil
176
174
case err := <- cm .errChan :
@@ -188,16 +186,10 @@ func (cm *controllerManager) Start(stop <-chan struct{}) error {
188
186
RetryPeriod : 2 * time .Second ,
189
187
Callbacks : leaderelection.LeaderCallbacks {
190
188
// This type changes in k8s 1.12 to func(context.Context)
191
- OnStartedLeading : func (stopleading <- chan struct {}) {
192
- // join both stop and stopleading so they feed into cm.stopper
193
- go func () {
194
- select {
195
- case <- stop :
196
- close (cm .stopper )
197
- case <- stopleading :
198
- close (cm .stopper )
199
- }
200
- }()
189
+ // Ignore the passed-in stop channel from leaderelection. The next
190
+ // thing it does anyway after closing its stop channel is call
191
+ // OnStoppedLeading.
192
+ OnStartedLeading : func (_ <- chan struct {}) {
201
193
cm .start ()
202
194
},
203
195
OnStoppedLeading : func () {
@@ -215,7 +207,7 @@ func (cm *controllerManager) Start(stop <-chan struct{}) error {
215
207
go l .Run ()
216
208
217
209
select {
218
- case <- cm . stop :
210
+ case <- stop :
219
211
// We are done
220
212
return nil
221
213
case err := <- cm .errChan :
You can’t perform that action at this time.
0 commit comments