mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
Merge pull request #127341 from mjudeikis/mjudeikis/deprecate.ch.fully
Fully deprecate StopCh
This commit is contained in:
commit
035e272cb1
@ -219,11 +219,11 @@ func (c completedConfig) New(delegationTarget genericapiserver.DelegationTarget)
|
||||
crdHandler,
|
||||
)
|
||||
|
||||
s.GenericAPIServer.AddPostStartHookOrDie("start-apiextensions-informers", func(context genericapiserver.PostStartHookContext) error {
|
||||
s.Informers.Start(context.Done())
|
||||
s.GenericAPIServer.AddPostStartHookOrDie("start-apiextensions-informers", func(hookContext genericapiserver.PostStartHookContext) error {
|
||||
s.Informers.Start(hookContext.Done())
|
||||
return nil
|
||||
})
|
||||
s.GenericAPIServer.AddPostStartHookOrDie("start-apiextensions-controllers", func(context genericapiserver.PostStartHookContext) error {
|
||||
s.GenericAPIServer.AddPostStartHookOrDie("start-apiextensions-controllers", func(hookContext genericapiserver.PostStartHookContext) error {
|
||||
// OpenAPIVersionedService and StaticOpenAPISpec are populated in generic apiserver PrepareRun().
|
||||
// Together they serve the /openapi/v2 endpoint on a generic apiserver. A generic apiserver may
|
||||
// choose to not enable OpenAPI by having null openAPIConfig, and thus OpenAPIVersionedService
|
||||
@ -231,25 +231,25 @@ func (c completedConfig) New(delegationTarget genericapiserver.DelegationTarget)
|
||||
if s.GenericAPIServer.StaticOpenAPISpec != nil {
|
||||
if s.GenericAPIServer.OpenAPIVersionedService != nil {
|
||||
openapiController := openapicontroller.NewController(s.Informers.Apiextensions().V1().CustomResourceDefinitions())
|
||||
go openapiController.Run(s.GenericAPIServer.StaticOpenAPISpec, s.GenericAPIServer.OpenAPIVersionedService, context.Done())
|
||||
go openapiController.Run(s.GenericAPIServer.StaticOpenAPISpec, s.GenericAPIServer.OpenAPIVersionedService, hookContext.Done())
|
||||
}
|
||||
|
||||
if s.GenericAPIServer.OpenAPIV3VersionedService != nil {
|
||||
openapiv3Controller := openapiv3controller.NewController(s.Informers.Apiextensions().V1().CustomResourceDefinitions())
|
||||
go openapiv3Controller.Run(s.GenericAPIServer.OpenAPIV3VersionedService, context.Done())
|
||||
go openapiv3Controller.Run(s.GenericAPIServer.OpenAPIV3VersionedService, hookContext.Done())
|
||||
}
|
||||
}
|
||||
|
||||
go namingController.Run(context.Done())
|
||||
go establishingController.Run(context.Done())
|
||||
go nonStructuralSchemaController.Run(5, context.Done())
|
||||
go apiApprovalController.Run(5, context.Done())
|
||||
go finalizingController.Run(5, context.Done())
|
||||
go namingController.Run(hookContext.Done())
|
||||
go establishingController.Run(hookContext.Done())
|
||||
go nonStructuralSchemaController.Run(5, hookContext.Done())
|
||||
go apiApprovalController.Run(5, hookContext.Done())
|
||||
go finalizingController.Run(5, hookContext.Done())
|
||||
|
||||
discoverySyncedCh := make(chan struct{})
|
||||
go discoveryController.Run(context.StopCh, discoverySyncedCh)
|
||||
go discoveryController.Run(hookContext.Done(), discoverySyncedCh)
|
||||
select {
|
||||
case <-context.StopCh:
|
||||
case <-hookContext.Done():
|
||||
case <-discoverySyncedCh:
|
||||
}
|
||||
|
||||
|
@ -886,8 +886,8 @@ func (c completedConfig) New(name string, delegationTarget DelegationTarget) (*G
|
||||
genericApiServerHookName := "generic-apiserver-start-informers"
|
||||
if c.SharedInformerFactory != nil {
|
||||
if !s.isPostStartHookRegistered(genericApiServerHookName) {
|
||||
err := s.AddPostStartHook(genericApiServerHookName, func(context PostStartHookContext) error {
|
||||
c.SharedInformerFactory.Start(context.StopCh)
|
||||
err := s.AddPostStartHook(genericApiServerHookName, func(hookContext PostStartHookContext) error {
|
||||
c.SharedInformerFactory.Start(hookContext.Done())
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
@ -904,8 +904,8 @@ func (c completedConfig) New(name string, delegationTarget DelegationTarget) (*G
|
||||
const priorityAndFairnessConfigConsumerHookName = "priority-and-fairness-config-consumer"
|
||||
if s.isPostStartHookRegistered(priorityAndFairnessConfigConsumerHookName) {
|
||||
} else if c.FlowControl != nil {
|
||||
err := s.AddPostStartHook(priorityAndFairnessConfigConsumerHookName, func(context PostStartHookContext) error {
|
||||
go c.FlowControl.Run(context.StopCh)
|
||||
err := s.AddPostStartHook(priorityAndFairnessConfigConsumerHookName, func(hookContext PostStartHookContext) error {
|
||||
go c.FlowControl.Run(hookContext.Done())
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
@ -920,8 +920,8 @@ func (c completedConfig) New(name string, delegationTarget DelegationTarget) (*G
|
||||
if c.FlowControl != nil {
|
||||
const priorityAndFairnessFilterHookName = "priority-and-fairness-filter"
|
||||
if !s.isPostStartHookRegistered(priorityAndFairnessFilterHookName) {
|
||||
err := s.AddPostStartHook(priorityAndFairnessFilterHookName, func(context PostStartHookContext) error {
|
||||
genericfilters.StartPriorityAndFairnessWatermarkMaintenance(context.StopCh)
|
||||
err := s.AddPostStartHook(priorityAndFairnessFilterHookName, func(hookContext PostStartHookContext) error {
|
||||
genericfilters.StartPriorityAndFairnessWatermarkMaintenance(hookContext.Done())
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
@ -931,8 +931,8 @@ func (c completedConfig) New(name string, delegationTarget DelegationTarget) (*G
|
||||
} else {
|
||||
const maxInFlightFilterHookName = "max-in-flight-filter"
|
||||
if !s.isPostStartHookRegistered(maxInFlightFilterHookName) {
|
||||
err := s.AddPostStartHook(maxInFlightFilterHookName, func(context PostStartHookContext) error {
|
||||
genericfilters.StartMaxInFlightWatermarkMaintenance(context.StopCh)
|
||||
err := s.AddPostStartHook(maxInFlightFilterHookName, func(hookContext PostStartHookContext) error {
|
||||
genericfilters.StartMaxInFlightWatermarkMaintenance(hookContext.Done())
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
@ -945,8 +945,8 @@ func (c completedConfig) New(name string, delegationTarget DelegationTarget) (*G
|
||||
if c.StorageObjectCountTracker != nil {
|
||||
const storageObjectCountTrackerHookName = "storage-object-count-tracker-hook"
|
||||
if !s.isPostStartHookRegistered(storageObjectCountTrackerHookName) {
|
||||
if err := s.AddPostStartHook(storageObjectCountTrackerHookName, func(context PostStartHookContext) error {
|
||||
go c.StorageObjectCountTracker.RunUntil(context.StopCh)
|
||||
if err := s.AddPostStartHook(storageObjectCountTrackerHookName, func(hookContext PostStartHookContext) error {
|
||||
go c.StorageObjectCountTracker.RunUntil(hookContext.Done())
|
||||
return nil
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
|
@ -49,11 +49,6 @@ type PreShutdownHookFunc func() error
|
||||
type PostStartHookContext struct {
|
||||
// LoopbackClientConfig is a config for a privileged loopback connection to the API server
|
||||
LoopbackClientConfig *restclient.Config
|
||||
// StopCh is the channel that will be closed when the server stops.
|
||||
//
|
||||
// Deprecated: use the PostStartHookContext itself instead, it contains a context that
|
||||
// gets cancelled when the server stops. StopCh keeps getting provided for existing code.
|
||||
StopCh <-chan struct{}
|
||||
// Context gets cancelled when the server stops.
|
||||
context.Context
|
||||
}
|
||||
@ -165,7 +160,6 @@ func (s *GenericAPIServer) RunPostStartHooks(ctx context.Context) {
|
||||
|
||||
context := PostStartHookContext{
|
||||
LoopbackClientConfig: s.LoopbackClientConfig,
|
||||
StopCh: ctx.Done(),
|
||||
Context: ctx,
|
||||
}
|
||||
|
||||
|
@ -157,9 +157,9 @@ func (a *AdmissionOptions) ApplyTo(
|
||||
initializersChain := admission.PluginInitializers{genericInitializer}
|
||||
initializersChain = append(initializersChain, pluginInitializers...)
|
||||
|
||||
admissionPostStartHook := func(context server.PostStartHookContext) error {
|
||||
admissionPostStartHook := func(hookContext server.PostStartHookContext) error {
|
||||
discoveryRESTMapper.Reset()
|
||||
go utilwait.Until(discoveryRESTMapper.Reset, 30*time.Second, context.StopCh)
|
||||
go utilwait.Until(discoveryRESTMapper.Reset, 30*time.Second, hookContext.Done())
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,6 @@ func TestStorageReadinessHookTimeout(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
hookCtx := PostStartHookContext{
|
||||
LoopbackClientConfig: nil,
|
||||
StopCh: ctx.Done(),
|
||||
Context: ctx,
|
||||
}
|
||||
if err := h.Hook(hookCtx); err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user