From 07864d1f1f070d957ac455d9b68092b3384b375d Mon Sep 17 00:00:00 2001 From: Mangirdas Judeikis Date: Sun, 23 Jun 2024 20:19:05 +0300 Subject: [PATCH 1/2] add Extra.DisableAvailableConditionController for kube-aggregator --- .../pkg/apiserver/apiserver.go | 55 ++++++++++++------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/staging/src/k8s.io/kube-aggregator/pkg/apiserver/apiserver.go b/staging/src/k8s.io/kube-aggregator/pkg/apiserver/apiserver.go index bfd1135e787..bf017f1f5bf 100644 --- a/staging/src/k8s.io/kube-aggregator/pkg/apiserver/apiserver.go +++ b/staging/src/k8s.io/kube-aggregator/pkg/apiserver/apiserver.go @@ -96,6 +96,13 @@ type ExtraConfig struct { ServiceResolver ServiceResolver RejectForwardingRedirects bool + + // DisableAvailableConditionController disables the controller that updates the Available conditions for + // APIServices, Endpoints and Services. This controller runs in kube-aggregator and can interfere with + // Generic Control Plane components when certain apis are not available. + // TODO: We should find a better way to handle this. For now it will be for Generic Control Plane authors to + // disable this controller if they see issues. + DisableAvailableConditionController bool } // Config represents the configuration needed to create an APIAggregator. @@ -310,24 +317,35 @@ func (c completedConfig) NewWithDelegate(delegationTarget genericapiserver.Deleg }) } - availableController, err := statuscontrollers.NewAvailableConditionController( - informerFactory.Apiregistration().V1().APIServices(), - c.GenericConfig.SharedInformerFactory.Core().V1().Services(), - c.GenericConfig.SharedInformerFactory.Core().V1().Endpoints(), - apiregistrationClient.ApiregistrationV1(), - proxyTransportDial, - (func() ([]byte, []byte))(s.proxyCurrentCertKeyContent), - s.serviceResolver, - ) - if err != nil { - return nil, err + // If the AvailableConditionController is disabled, we don't need to start the informers + // and the controller. + if !c.ExtraConfig.DisableAvailableConditionController { + availableController, err := statuscontrollers.NewAvailableConditionController( + informerFactory.Apiregistration().V1().APIServices(), + c.GenericConfig.SharedInformerFactory.Core().V1().Services(), + c.GenericConfig.SharedInformerFactory.Core().V1().Endpoints(), + apiregistrationClient.ApiregistrationV1(), + proxyTransportDial, + (func() ([]byte, []byte))(s.proxyCurrentCertKeyContent), + s.serviceResolver, + ) + if err != nil { + return nil, err + } + + s.GenericAPIServer.AddPostStartHookOrDie("start-kube-aggregator-informers", func(context genericapiserver.PostStartHookContext) error { + informerFactory.Start(context.StopCh) + c.GenericConfig.SharedInformerFactory.Start(context.StopCh) + return nil + }) + + s.GenericAPIServer.AddPostStartHookOrDie("apiservice-status-available-controller", func(context genericapiserver.PostStartHookContext) error { + // if we end up blocking for long periods of time, we may need to increase workers. + go availableController.Run(5, context.StopCh) + return nil + }) } - s.GenericAPIServer.AddPostStartHookOrDie("start-kube-aggregator-informers", func(context genericapiserver.PostStartHookContext) error { - informerFactory.Start(context.StopCh) - c.GenericConfig.SharedInformerFactory.Start(context.StopCh) - return nil - }) s.GenericAPIServer.AddPostStartHookOrDie("apiservice-registration-controller", func(context genericapiserver.PostStartHookContext) error { go apiserviceRegistrationController.Run(context.StopCh, apiServiceRegistrationControllerInitiated) select { @@ -337,11 +355,6 @@ func (c completedConfig) NewWithDelegate(delegationTarget genericapiserver.Deleg return nil }) - s.GenericAPIServer.AddPostStartHookOrDie("apiservice-status-available-controller", func(context genericapiserver.PostStartHookContext) error { - // if we end up blocking for long periods of time, we may need to increase workers. - go availableController.Run(5, context.StopCh) - return nil - }) if utilfeature.DefaultFeatureGate.Enabled(genericfeatures.AggregatedDiscoveryEndpoint) { s.discoveryAggregationController = NewDiscoveryManager( From 539eb53c9ae70e2faf7e60107f4099124e4d2b06 Mon Sep 17 00:00:00 2001 From: Mangirdas Judeikis Date: Mon, 24 Jun 2024 11:47:06 +0300 Subject: [PATCH 2/2] deprecation fix --- .../src/k8s.io/kube-aggregator/pkg/apiserver/apiserver.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/staging/src/k8s.io/kube-aggregator/pkg/apiserver/apiserver.go b/staging/src/k8s.io/kube-aggregator/pkg/apiserver/apiserver.go index bf017f1f5bf..ac9cc156240 100644 --- a/staging/src/k8s.io/kube-aggregator/pkg/apiserver/apiserver.go +++ b/staging/src/k8s.io/kube-aggregator/pkg/apiserver/apiserver.go @@ -334,14 +334,14 @@ func (c completedConfig) NewWithDelegate(delegationTarget genericapiserver.Deleg } s.GenericAPIServer.AddPostStartHookOrDie("start-kube-aggregator-informers", func(context genericapiserver.PostStartHookContext) error { - informerFactory.Start(context.StopCh) - c.GenericConfig.SharedInformerFactory.Start(context.StopCh) + informerFactory.Start(context.Done()) + c.GenericConfig.SharedInformerFactory.Start(context.Done()) return nil }) s.GenericAPIServer.AddPostStartHookOrDie("apiservice-status-available-controller", func(context genericapiserver.PostStartHookContext) error { // if we end up blocking for long periods of time, we may need to increase workers. - go availableController.Run(5, context.StopCh) + go availableController.Run(5, context.Done()) return nil }) }