Skip to content

Commit 79c81fa

Browse files
authored
Merge pull request kubernetes#124620 from sttts/sttts-controlplane-cosmetics
controlplane: cosmetics
2 parents d0fddf1 + b8d7e2e commit 79c81fa

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

pkg/controlplane/apiserver/config.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ type Extra struct {
9595
VersionedInformers clientgoinformers.SharedInformerFactory
9696
}
9797

98-
// BuildGenericConfig takes the master server options and produces the genericapiserver.Config associated with it
98+
// BuildGenericConfig takes the generic controlplane apiserver options and produces
99+
// the genericapiserver.Config associated with it. The genericapiserver.Config is
100+
// often shared between multiple delegated apiservers.
99101
func BuildGenericConfig(
100102
s controlplaneapiserver.CompletedOptions,
101103
schemes []*runtime.Scheme,
@@ -130,7 +132,7 @@ func BuildGenericConfig(
130132
kubeClientConfig := genericConfig.LoopbackClientConfig
131133
clientgoExternalClient, err := clientgoclientset.NewForConfig(kubeClientConfig)
132134
if err != nil {
133-
lastErr = fmt.Errorf("failed to create real external clientset: %v", err)
135+
lastErr = fmt.Errorf("failed to create real external clientset: %w", err)
134136
return
135137
}
136138
versionedInformers = clientgoinformers.NewSharedInformerFactory(clientgoExternalClient, 10*time.Minute)
@@ -203,7 +205,7 @@ func BuildGenericConfig(
203205
versionedInformers,
204206
)
205207
if err != nil {
206-
lastErr = fmt.Errorf("invalid authorization config: %v", err)
208+
lastErr = fmt.Errorf("invalid authorization config: %w", err)
207209
return
208210
}
209211
if s.Authorization != nil && !enablesRBAC {

pkg/controlplane/apiserver/server.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,10 @@ func (c completedConfig) New(name string, delegationTarget genericapiserver.Dele
133133
VersionedInformers: c.VersionedInformers,
134134
}
135135

136-
client := kubernetes.NewForConfigOrDie(s.GenericAPIServer.LoopbackClientConfig)
136+
client, err := kubernetes.NewForConfig(s.GenericAPIServer.LoopbackClientConfig)
137+
if err != nil {
138+
return nil, err
139+
}
137140
if len(c.SystemNamespaces) > 0 {
138141
s.GenericAPIServer.AddPostStartHookOrDie("start-system-namespaces-controller", func(hookContext genericapiserver.PostStartHookContext) error {
139142
go systemnamespaces.NewController(c.SystemNamespaces, client, s.VersionedInformers.Core().V1().Namespaces()).Run(hookContext.StopCh)

0 commit comments

Comments
 (0)