Skip to content

Commit e2b0094

Browse files
authored
fix: stopCh can't work for start operator (#1857)
1 parent 85ec4d2 commit e2b0094

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

pkg/controller/main-controller.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -592,19 +592,22 @@ func (c *Controller) Start(threadiness int, stopCh <-chan struct{}) error {
592592
Err: nil,
593593
}
594594
}()
595-
596-
for oerr := range notificationChannel {
597-
switch oerr.Type {
598-
case STSServerNotification:
599-
if !errors.Is(oerr.Err, http.ErrServerClosed) {
600-
klog.Errorf("STS API Server stopped: %v, going to restart", oerr.Err)
601-
go c.startSTSAPIServer(ctx, notificationChannel)
595+
for {
596+
select {
597+
case oerr := <-notificationChannel:
598+
switch oerr.Type {
599+
case STSServerNotification:
600+
if !errors.Is(oerr.Err, http.ErrServerClosed) {
601+
klog.Errorf("STS API Server stopped: %v, going to restart", oerr.Err)
602+
go c.startSTSAPIServer(ctx, notificationChannel)
603+
}
604+
case LeaderElection:
605+
return nil
602606
}
603-
case LeaderElection:
607+
case <-stopCh:
604608
return nil
605609
}
606610
}
607-
return nil
608611
}
609612

610613
// Stop is called to shutdown the controller

0 commit comments

Comments
 (0)