@@ -73,7 +73,7 @@ func NewController(
7373 shardInformer corev1alpha1informers.ShardInformer ,
7474 clientGetter ClusterClientGetter ,
7575 baseAudiences authenticator.Audiences ,
76- ) * Controller {
76+ ) ( * Controller , error ) {
7777 queue := workqueue .NewTypedRateLimitingQueueWithConfig (
7878 workqueue .DefaultTypedControllerRateLimiter [string ](),
7979 workqueue.TypedRateLimitingQueueConfig [string ]{
@@ -93,7 +93,7 @@ func NewController(
9393 shardWatchers : map [string ]* shardWatcher {},
9494 }
9595
96- _ , _ = shardInformer .Informer ().AddEventHandler (cache.ResourceEventHandlerFuncs {
96+ _ , err : = shardInformer .Informer ().AddEventHandler (cache.ResourceEventHandlerFuncs {
9797 AddFunc : func (obj interface {}) {
9898 shard := obj .(* corev1alpha1.Shard )
9999 c .enqueueShard (ctx , shard )
@@ -116,8 +116,11 @@ func NewController(
116116 c .stopShard (shard .Name )
117117 },
118118 })
119+ if err != nil {
120+ return nil , fmt .Errorf ("failed to start Shard informer: %w" , err )
121+ }
119122
120- return c
123+ return c , nil
121124}
122125
123126// Start the controller. It does not really do anything, but to keep the shape of a normal
@@ -215,7 +218,11 @@ func (c *Controller) process(ctx context.Context, key string) error {
215218 return err
216219 }
217220
218- watcher := NewShardWatcher (ctx , shard .Name , client , & c .authIndex )
221+ watcher , err := NewShardWatcher (ctx , shard .Name , client , & c .authIndex )
222+ if err != nil {
223+ return fmt .Errorf ("failed to start shard watcher: %w" , err )
224+ }
225+
219226 c .shardWatchers [shard .Name ] = watcher
220227 }
221228
@@ -250,9 +257,9 @@ func NewShardWatcher(
250257 shardName string ,
251258 shardClient kcpclientset.ClusterInterface ,
252259 state * state ,
253- ) * shardWatcher {
260+ ) ( * shardWatcher , error ) {
254261 wacInformer := tenancyv1alpha1informers .NewWorkspaceAuthenticationConfigurationClusterInformer (shardClient , resyncPeriod , nil )
255- _ , _ = wacInformer .AddEventHandler (cache.ResourceEventHandlerFuncs {
262+ _ , err : = wacInformer .AddEventHandler (cache.ResourceEventHandlerFuncs {
256263 AddFunc : func (obj interface {}) {
257264 wac := obj .(* tenancyv1alpha1.WorkspaceAuthenticationConfiguration )
258265 state .UpsertWorkspaceAuthenticationConfiguration (shardName , wac )
@@ -269,9 +276,12 @@ func NewShardWatcher(
269276 state .DeleteWorkspaceAuthenticationConfiguration (shardName , wac )
270277 },
271278 })
279+ if err != nil {
280+ return nil , fmt .Errorf ("failed to start WorkspaceAuthenticationConfiguration informer: %w" , err )
281+ }
272282
273283 wtInformer := tenancyv1alpha1informers .NewWorkspaceTypeClusterInformer (shardClient , resyncPeriod , nil )
274- _ , _ = wtInformer .AddEventHandler (cache.ResourceEventHandlerFuncs {
284+ _ , err = wtInformer .AddEventHandler (cache.ResourceEventHandlerFuncs {
275285 AddFunc : func (obj interface {}) {
276286 wt := obj .(* tenancyv1alpha1.WorkspaceType )
277287 state .UpsertWorkspaceType (shardName , wt )
@@ -288,6 +298,9 @@ func NewShardWatcher(
288298 state .DeleteWorkspaceType (shardName , wt )
289299 },
290300 })
301+ if err != nil {
302+ return nil , fmt .Errorf ("failed to start WorkspaceType informer: %w" , err )
303+ }
291304
292305 ctx , cancel := context .WithCancel (ctx )
293306
@@ -303,7 +316,7 @@ func NewShardWatcher(
303316
304317 // no need to wait. We only care about events and they arrive when they arrive.
305318
306- return watcher
319+ return watcher , nil
307320}
308321
309322func (w * shardWatcher ) Stop () {
0 commit comments