@@ -346,6 +346,34 @@ func NewMPIJobControllerWithClock(
346346
347347 controller .updateStatusHandler = controller .doUpdateJobStatus
348348
349+ // Set up error handlers for informers
350+ klog .Info ("Setting up informer error handlers" )
351+ informers := map [string ]cache.SharedInformer {
352+ "configMapInformer" : configMapInformer .Informer (),
353+ "secretInformer" : secretInformer .Informer (),
354+ "serviceInformer" : serviceInformer .Informer (),
355+ "jobInformer" : jobInformer .Informer (),
356+ "podInformer" : podInformer .Informer (),
357+ "priorityClassInformer" : priorityClassInformer .Informer (),
358+ "mpiJobInformer" : mpiJobInformer .Informer (),
359+ }
360+
361+ for name , informer := range informers {
362+ err := informer .SetWatchErrorHandler (func (r * cache.Reflector , err error ) {
363+ // Pipe to default handler first, which just logs the error
364+ cache .DefaultWatchErrorHandler (r , err )
365+
366+ if errors .IsUnauthorized (err ) || errors .IsForbidden (err ) {
367+ klog .Fatalf ("Unable to sync cache for informer %s: %s. Requesting controller to exit." , name , err )
368+ }
369+ })
370+
371+ if err != nil {
372+ // return NewMPIJobControllerWithClock(...) (nil, error)
373+ return nil , fmt .Errorf ("unable to set error handler for informer %s: %s" , name , err )
374+ }
375+ }
376+
349377 klog .Info ("Setting up event handlers" )
350378 // Set up an event handler for when MPIJob resources change.
351379 if _ , err := mpiJobInformer .Informer ().AddEventHandler (cache.ResourceEventHandlerFuncs {
0 commit comments