Skip to content

Commit c5aba51

Browse files
committed
config: Shutdown CVO if configuration controller fails to start
An error in the start logic will now result in the immediate shutdown of the CVO, rather than in the CVO catching the failed controller and continuing to work by ignoring the failed start.
1 parent 12099d8 commit c5aba51

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

pkg/cvo/cvo.go

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,9 @@ func (optr *Operator) Run(runContext context.Context, shutdownContext context.Co
446446
defer optr.queue.ShutDown()
447447
defer optr.availableUpdatesQueue.ShutDown()
448448
defer optr.upgradeableQueue.ShutDown()
449-
defer optr.configuration.Queue().ShutDown()
449+
if optr.configuration != nil {
450+
defer optr.configuration.Queue().ShutDown()
451+
}
450452
stopCh := runContext.Done()
451453

452454
klog.Infof("Starting ClusterVersionOperator with minimum reconcile period %s", optr.minimumUpdateCheckInterval)
@@ -459,6 +461,12 @@ func (optr *Operator) Run(runContext context.Context, shutdownContext context.Co
459461
return fmt.Errorf("caches never synchronized: %w", runContext.Err())
460462
}
461463

464+
if optr.configuration != nil {
465+
if err := optr.configuration.Start(runContext); err != nil {
466+
return fmt.Errorf("unable to initialize the CVO configuration controller: %v", err)
467+
}
468+
}
469+
462470
// trigger the first cluster version reconcile always
463471
optr.queue.Add(optr.queueKey())
464472

@@ -489,13 +497,9 @@ func (optr *Operator) Run(runContext context.Context, shutdownContext context.Co
489497
resultChannelCount++
490498
go func() {
491499
defer utilruntime.HandleCrash()
492-
if err := optr.configuration.Start(runContext); err != nil {
493-
utilruntime.HandleError(fmt.Errorf("unable to initialize the CVO configuration sync: %v", err))
494-
} else {
495-
wait.UntilWithContext(runContext, func(runContext context.Context) {
496-
optr.worker(runContext, optr.configuration.Queue(), optr.configuration.Sync)
497-
}, time.Second)
498-
}
500+
wait.UntilWithContext(runContext, func(runContext context.Context) {
501+
optr.worker(runContext, optr.configuration.Queue(), optr.configuration.Sync)
502+
}, time.Second)
499503
resultChannel <- asyncResult{name: "cvo configuration"}
500504
}()
501505
} else {
@@ -571,7 +575,9 @@ func (optr *Operator) Run(runContext context.Context, shutdownContext context.Co
571575
optr.queue.ShutDown()
572576
optr.availableUpdatesQueue.ShutDown()
573577
optr.upgradeableQueue.ShutDown()
574-
optr.configuration.Queue().ShutDown()
578+
if optr.configuration != nil {
579+
optr.configuration.Queue().ShutDown()
580+
}
575581
}
576582
}
577583

0 commit comments

Comments
 (0)