fix: Ensure we keep observing

This commit is contained in:
Dries De Peuter 2023-04-27 09:56:31 +02:00
parent 01946451cb
commit f17f8acfef
No known key found for this signature in database

View file

@ -108,7 +108,10 @@ func main() {
RetryPeriod: 5 * time.Second, RetryPeriod: 5 * time.Second,
Callbacks: leaderelection.LeaderCallbacks{ Callbacks: leaderelection.LeaderCallbacks{
OnStartedLeading: func(ctx context.Context) { OnStartedLeading: func(ctx context.Context) {
for {
// ensure that we keep observing
loop(ctx, clientset) loop(ctx, clientset)
}
}, },
OnStoppedLeading: func() { OnStoppedLeading: func() {
klog.Infof("leader lost: %s", id) klog.Infof("leader lost: %s", id)
@ -155,7 +158,6 @@ func loop(ctx context.Context, clientset *kubernetes.Clientset) {
klog.Error(err) klog.Error(err)
} }
}) })
} }
} }