Skip to content

Commit bf8152a

Browse files
mjudeikisk8s-publishing-bot
authored andcommitted
clean deprecated context.StopCh
Kubernetes-commit: 24ecb20e412cd545207a0c95cd62476f53b6d047
1 parent d4566e5 commit bf8152a

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

pkg/apiserver/apiserver.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ func (c completedConfig) NewWithDelegate(delegationTarget genericapiserver.Deleg
310310
ctx, cancel := context.WithCancel(context.Background())
311311
go func() {
312312
select {
313-
case <-postStartHookContext.StopCh:
313+
case <-postStartHookContext.Done():
314314
cancel() // stopCh closed, so cancel our context
315315
case <-ctx.Done():
316316
}
@@ -373,9 +373,9 @@ func (c completedConfig) NewWithDelegate(delegationTarget genericapiserver.Deleg
373373
}
374374

375375
s.GenericAPIServer.AddPostStartHookOrDie("apiservice-registration-controller", func(context genericapiserver.PostStartHookContext) error {
376-
go apiserviceRegistrationController.Run(context.StopCh, apiServiceRegistrationControllerInitiated)
376+
go apiserviceRegistrationController.Run(context.Done(), apiServiceRegistrationControllerInitiated)
377377
select {
378-
case <-context.StopCh:
378+
case <-context.Done():
379379
case <-apiServiceRegistrationControllerInitiated:
380380
}
381381

@@ -394,7 +394,7 @@ func (c completedConfig) NewWithDelegate(delegationTarget genericapiserver.Deleg
394394
// Discovery aggregation depends on the apiservice registration controller
395395
// having the full list of APIServices already synced
396396
select {
397-
case <-context.StopCh:
397+
case <-context.Done():
398398
return nil
399399
// Context cancelled, should abort/clean goroutines
400400
case <-apiServiceRegistrationControllerInitiated:
@@ -405,10 +405,10 @@ func (c completedConfig) NewWithDelegate(delegationTarget genericapiserver.Deleg
405405
// When discovery is ready, all APIServices will be present, with APIServices
406406
// that have not successfully synced discovery to be present but marked as Stale.
407407
discoverySyncedCh := make(chan struct{})
408-
go s.discoveryAggregationController.Run(context.StopCh, discoverySyncedCh)
408+
go s.discoveryAggregationController.Run(context.Done(), discoverySyncedCh)
409409

410410
select {
411-
case <-context.StopCh:
411+
case <-context.Done():
412412
return nil
413413
// Context cancelled, should abort/clean goroutines
414414
case <-discoverySyncedCh:
@@ -440,7 +440,7 @@ func (c completedConfig) NewWithDelegate(delegationTarget genericapiserver.Deleg
440440
return false, err
441441
}
442442
return true, nil
443-
}, hookContext.StopCh); err != nil {
443+
}, hookContext.Done()); err != nil {
444444
return fmt.Errorf("failed to wait for apiserver-identity lease %s to be created: %v",
445445
s.GenericAPIServer.APIServerID, err)
446446
}
@@ -456,14 +456,14 @@ func (c completedConfig) NewWithDelegate(delegationTarget genericapiserver.Deleg
456456
// to register all built-in resources when the generic apiservers install APIs.
457457
s.GenericAPIServer.StorageVersionManager.UpdateStorageVersions(hookContext.LoopbackClientConfig, s.GenericAPIServer.APIServerID)
458458
return false, nil
459-
}, hookContext.StopCh)
459+
}, hookContext.Done())
460460
// Once the storage version updater finishes the first round of update,
461461
// the PostStartHook will return to unblock /healthz. The handler chain
462462
// won't block write requests anymore. Check every second since it's not
463463
// expensive.
464464
wait.PollImmediateUntil(1*time.Second, func() (bool, error) {
465465
return s.GenericAPIServer.StorageVersionManager.Completed(), nil
466-
}, hookContext.StopCh)
466+
}, hookContext.Done())
467467
return nil
468468
})
469469
}
@@ -477,14 +477,14 @@ func (s *APIAggregator) PrepareRun() (preparedAPIAggregator, error) {
477477
// add post start hook before generic PrepareRun in order to be before /healthz installation
478478
if s.openAPIConfig != nil {
479479
s.GenericAPIServer.AddPostStartHookOrDie("apiservice-openapi-controller", func(context genericapiserver.PostStartHookContext) error {
480-
go s.openAPIAggregationController.Run(context.StopCh)
480+
go s.openAPIAggregationController.Run(context.Done())
481481
return nil
482482
})
483483
}
484484

485485
if s.openAPIV3Config != nil {
486486
s.GenericAPIServer.AddPostStartHookOrDie("apiservice-openapiv3-controller", func(context genericapiserver.PostStartHookContext) error {
487-
go s.openAPIV3AggregationController.Run(context.StopCh)
487+
go s.openAPIV3AggregationController.Run(context.Done())
488488
return nil
489489
})
490490
}

0 commit comments

Comments
 (0)