mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 17:30: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,
|
crdHandler,
|
||||||
)
|
)
|
||||||
|
|
||||||
s.GenericAPIServer.AddPostStartHookOrDie("start-apiextensions-informers", func(context genericapiserver.PostStartHookContext) error {
|
s.GenericAPIServer.AddPostStartHookOrDie("start-apiextensions-informers", func(hookContext genericapiserver.PostStartHookContext) error {
|
||||||
s.Informers.Start(context.Done())
|
s.Informers.Start(hookContext.Done())
|
||||||
return nil
|
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().
|
// OpenAPIVersionedService and StaticOpenAPISpec are populated in generic apiserver PrepareRun().
|
||||||
// Together they serve the /openapi/v2 endpoint on a generic apiserver. A generic apiserver may
|
// 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
|
// 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.StaticOpenAPISpec != nil {
|
||||||
if s.GenericAPIServer.OpenAPIVersionedService != nil {
|
if s.GenericAPIServer.OpenAPIVersionedService != nil {
|
||||||
openapiController := openapicontroller.NewController(s.Informers.Apiextensions().V1().CustomResourceDefinitions())
|
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 {
|
if s.GenericAPIServer.OpenAPIV3VersionedService != nil {
|
||||||
openapiv3Controller := openapiv3controller.NewController(s.Informers.Apiextensions().V1().CustomResourceDefinitions())
|
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 namingController.Run(hookContext.Done())
|
||||||
go establishingController.Run(context.Done())
|
go establishingController.Run(hookContext.Done())
|
||||||
go nonStructuralSchemaController.Run(5, context.Done())
|
go nonStructuralSchemaController.Run(5, hookContext.Done())
|
||||||
go apiApprovalController.Run(5, context.Done())
|
go apiApprovalController.Run(5, hookContext.Done())
|
||||||
go finalizingController.Run(5, context.Done())
|
go finalizingController.Run(5, hookContext.Done())
|
||||||
|
|
||||||
discoverySyncedCh := make(chan struct{})
|
discoverySyncedCh := make(chan struct{})
|
||||||
go discoveryController.Run(context.StopCh, discoverySyncedCh)
|
go discoveryController.Run(hookContext.Done(), discoverySyncedCh)
|
||||||
select {
|
select {
|
||||||
case <-context.StopCh:
|
case <-hookContext.Done():
|
||||||
case <-discoverySyncedCh:
|
case <-discoverySyncedCh:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -886,8 +886,8 @@ func (c completedConfig) New(name string, delegationTarget DelegationTarget) (*G
|
|||||||
genericApiServerHookName := "generic-apiserver-start-informers"
|
genericApiServerHookName := "generic-apiserver-start-informers"
|
||||||
if c.SharedInformerFactory != nil {
|
if c.SharedInformerFactory != nil {
|
||||||
if !s.isPostStartHookRegistered(genericApiServerHookName) {
|
if !s.isPostStartHookRegistered(genericApiServerHookName) {
|
||||||
err := s.AddPostStartHook(genericApiServerHookName, func(context PostStartHookContext) error {
|
err := s.AddPostStartHook(genericApiServerHookName, func(hookContext PostStartHookContext) error {
|
||||||
c.SharedInformerFactory.Start(context.StopCh)
|
c.SharedInformerFactory.Start(hookContext.Done())
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -904,8 +904,8 @@ func (c completedConfig) New(name string, delegationTarget DelegationTarget) (*G
|
|||||||
const priorityAndFairnessConfigConsumerHookName = "priority-and-fairness-config-consumer"
|
const priorityAndFairnessConfigConsumerHookName = "priority-and-fairness-config-consumer"
|
||||||
if s.isPostStartHookRegistered(priorityAndFairnessConfigConsumerHookName) {
|
if s.isPostStartHookRegistered(priorityAndFairnessConfigConsumerHookName) {
|
||||||
} else if c.FlowControl != nil {
|
} else if c.FlowControl != nil {
|
||||||
err := s.AddPostStartHook(priorityAndFairnessConfigConsumerHookName, func(context PostStartHookContext) error {
|
err := s.AddPostStartHook(priorityAndFairnessConfigConsumerHookName, func(hookContext PostStartHookContext) error {
|
||||||
go c.FlowControl.Run(context.StopCh)
|
go c.FlowControl.Run(hookContext.Done())
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -920,8 +920,8 @@ func (c completedConfig) New(name string, delegationTarget DelegationTarget) (*G
|
|||||||
if c.FlowControl != nil {
|
if c.FlowControl != nil {
|
||||||
const priorityAndFairnessFilterHookName = "priority-and-fairness-filter"
|
const priorityAndFairnessFilterHookName = "priority-and-fairness-filter"
|
||||||
if !s.isPostStartHookRegistered(priorityAndFairnessFilterHookName) {
|
if !s.isPostStartHookRegistered(priorityAndFairnessFilterHookName) {
|
||||||
err := s.AddPostStartHook(priorityAndFairnessFilterHookName, func(context PostStartHookContext) error {
|
err := s.AddPostStartHook(priorityAndFairnessFilterHookName, func(hookContext PostStartHookContext) error {
|
||||||
genericfilters.StartPriorityAndFairnessWatermarkMaintenance(context.StopCh)
|
genericfilters.StartPriorityAndFairnessWatermarkMaintenance(hookContext.Done())
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -931,8 +931,8 @@ func (c completedConfig) New(name string, delegationTarget DelegationTarget) (*G
|
|||||||
} else {
|
} else {
|
||||||
const maxInFlightFilterHookName = "max-in-flight-filter"
|
const maxInFlightFilterHookName = "max-in-flight-filter"
|
||||||
if !s.isPostStartHookRegistered(maxInFlightFilterHookName) {
|
if !s.isPostStartHookRegistered(maxInFlightFilterHookName) {
|
||||||
err := s.AddPostStartHook(maxInFlightFilterHookName, func(context PostStartHookContext) error {
|
err := s.AddPostStartHook(maxInFlightFilterHookName, func(hookContext PostStartHookContext) error {
|
||||||
genericfilters.StartMaxInFlightWatermarkMaintenance(context.StopCh)
|
genericfilters.StartMaxInFlightWatermarkMaintenance(hookContext.Done())
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -945,8 +945,8 @@ func (c completedConfig) New(name string, delegationTarget DelegationTarget) (*G
|
|||||||
if c.StorageObjectCountTracker != nil {
|
if c.StorageObjectCountTracker != nil {
|
||||||
const storageObjectCountTrackerHookName = "storage-object-count-tracker-hook"
|
const storageObjectCountTrackerHookName = "storage-object-count-tracker-hook"
|
||||||
if !s.isPostStartHookRegistered(storageObjectCountTrackerHookName) {
|
if !s.isPostStartHookRegistered(storageObjectCountTrackerHookName) {
|
||||||
if err := s.AddPostStartHook(storageObjectCountTrackerHookName, func(context PostStartHookContext) error {
|
if err := s.AddPostStartHook(storageObjectCountTrackerHookName, func(hookContext PostStartHookContext) error {
|
||||||
go c.StorageObjectCountTracker.RunUntil(context.StopCh)
|
go c.StorageObjectCountTracker.RunUntil(hookContext.Done())
|
||||||
return nil
|
return nil
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -49,11 +49,6 @@ type PreShutdownHookFunc func() error
|
|||||||
type PostStartHookContext struct {
|
type PostStartHookContext struct {
|
||||||
// LoopbackClientConfig is a config for a privileged loopback connection to the API server
|
// LoopbackClientConfig is a config for a privileged loopback connection to the API server
|
||||||
LoopbackClientConfig *restclient.Config
|
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 gets cancelled when the server stops.
|
||||||
context.Context
|
context.Context
|
||||||
}
|
}
|
||||||
@ -165,7 +160,6 @@ func (s *GenericAPIServer) RunPostStartHooks(ctx context.Context) {
|
|||||||
|
|
||||||
context := PostStartHookContext{
|
context := PostStartHookContext{
|
||||||
LoopbackClientConfig: s.LoopbackClientConfig,
|
LoopbackClientConfig: s.LoopbackClientConfig,
|
||||||
StopCh: ctx.Done(),
|
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,9 +157,9 @@ func (a *AdmissionOptions) ApplyTo(
|
|||||||
initializersChain := admission.PluginInitializers{genericInitializer}
|
initializersChain := admission.PluginInitializers{genericInitializer}
|
||||||
initializersChain = append(initializersChain, pluginInitializers...)
|
initializersChain = append(initializersChain, pluginInitializers...)
|
||||||
|
|
||||||
admissionPostStartHook := func(context server.PostStartHookContext) error {
|
admissionPostStartHook := func(hookContext server.PostStartHookContext) error {
|
||||||
discoveryRESTMapper.Reset()
|
discoveryRESTMapper.Reset()
|
||||||
go utilwait.Until(discoveryRESTMapper.Reset, 30*time.Second, context.StopCh)
|
go utilwait.Until(discoveryRESTMapper.Reset, 30*time.Second, hookContext.Done())
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +76,6 @@ func TestStorageReadinessHookTimeout(t *testing.T) {
|
|||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
hookCtx := PostStartHookContext{
|
hookCtx := PostStartHookContext{
|
||||||
LoopbackClientConfig: nil,
|
LoopbackClientConfig: nil,
|
||||||
StopCh: ctx.Done(),
|
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
}
|
}
|
||||||
if err := h.Hook(hookCtx); err != nil {
|
if err := h.Hook(hookCtx); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user