Merge pull request #124620 from sttts/sttts-controlplane-cosmetics

controlplane: cosmetics
This commit is contained in:
Kubernetes Prow Robot 2024-04-30 01:30:16 -07:00 committed by GitHub
commit 79c81fab61
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 4 deletions

View File

@ -95,7 +95,9 @@ type Extra struct {
VersionedInformers clientgoinformers.SharedInformerFactory VersionedInformers clientgoinformers.SharedInformerFactory
} }
// BuildGenericConfig takes the master server options and produces the genericapiserver.Config associated with it // BuildGenericConfig takes the generic controlplane apiserver options and produces
// the genericapiserver.Config associated with it. The genericapiserver.Config is
// often shared between multiple delegated apiservers.
func BuildGenericConfig( func BuildGenericConfig(
s controlplaneapiserver.CompletedOptions, s controlplaneapiserver.CompletedOptions,
schemes []*runtime.Scheme, schemes []*runtime.Scheme,
@ -130,7 +132,7 @@ func BuildGenericConfig(
kubeClientConfig := genericConfig.LoopbackClientConfig kubeClientConfig := genericConfig.LoopbackClientConfig
clientgoExternalClient, err := clientgoclientset.NewForConfig(kubeClientConfig) clientgoExternalClient, err := clientgoclientset.NewForConfig(kubeClientConfig)
if err != nil { if err != nil {
lastErr = fmt.Errorf("failed to create real external clientset: %v", err) lastErr = fmt.Errorf("failed to create real external clientset: %w", err)
return return
} }
versionedInformers = clientgoinformers.NewSharedInformerFactory(clientgoExternalClient, 10*time.Minute) versionedInformers = clientgoinformers.NewSharedInformerFactory(clientgoExternalClient, 10*time.Minute)
@ -203,7 +205,7 @@ func BuildGenericConfig(
versionedInformers, versionedInformers,
) )
if err != nil { if err != nil {
lastErr = fmt.Errorf("invalid authorization config: %v", err) lastErr = fmt.Errorf("invalid authorization config: %w", err)
return return
} }
if s.Authorization != nil && !enablesRBAC { if s.Authorization != nil && !enablesRBAC {

View File

@ -133,7 +133,10 @@ func (c completedConfig) New(name string, delegationTarget genericapiserver.Dele
VersionedInformers: c.VersionedInformers, VersionedInformers: c.VersionedInformers,
} }
client := kubernetes.NewForConfigOrDie(s.GenericAPIServer.LoopbackClientConfig) client, err := kubernetes.NewForConfig(s.GenericAPIServer.LoopbackClientConfig)
if err != nil {
return nil, err
}
if len(c.SystemNamespaces) > 0 { if len(c.SystemNamespaces) > 0 {
s.GenericAPIServer.AddPostStartHookOrDie("start-system-namespaces-controller", func(hookContext genericapiserver.PostStartHookContext) error { s.GenericAPIServer.AddPostStartHookOrDie("start-system-namespaces-controller", func(hookContext genericapiserver.PostStartHookContext) error {
go systemnamespaces.NewController(c.SystemNamespaces, client, s.VersionedInformers.Core().V1().Namespaces()).Run(hookContext.StopCh) go systemnamespaces.NewController(c.SystemNamespaces, client, s.VersionedInformers.Core().V1().Namespaces()).Run(hookContext.StopCh)