Skip to content

Commit 1332499

Browse files
committed
Error and exit on failure
Signed-off-by: Yuriy Losev <yuriy.losev@flant.com>
1 parent fb1dddb commit 1332499

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

vertical-pod-autoscaler/pkg/admission-controller/main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,10 @@ func main() {
120120
defer close(stopCh)
121121
factory.Start(stopCh)
122122
informerMap := factory.WaitForCacheSync(stopCh)
123-
for informerType, synced := range informerMap {
123+
for kind, synced := range informerMap {
124124
if !synced {
125-
klog.V(0).InfoS("Initial sync failed", "kind", informerType)
125+
klog.ErrorS(nil, fmt.Sprintf("Could not sync cache for the %s informer", kind.String()))
126+
klog.FlushAndExit(klog.ExitFlushTimeout, 1)
126127
}
127128
}
128129

vertical-pod-autoscaler/pkg/recommender/main.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package main
1919
import (
2020
"context"
2121
"flag"
22+
"fmt"
2223
"os"
2324
"strings"
2425
"time"
@@ -234,9 +235,10 @@ func run(ctx context.Context, healthCheck *metrics.HealthCheck, commonFlag *comm
234235

235236
factory.Start(stopCh)
236237
informerMap := factory.WaitForCacheSync(stopCh)
237-
for informerType, synced := range informerMap {
238+
for kind, synced := range informerMap {
238239
if !synced {
239-
klog.V(0).InfoS("Initial sync failed", "kind", informerType)
240+
klog.ErrorS(nil, fmt.Sprintf("Could not sync cache for the %s informer", kind.String()))
241+
klog.FlushAndExit(klog.ExitFlushTimeout, 1)
240242
}
241243
}
242244

vertical-pod-autoscaler/pkg/updater/main.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package main
1919
import (
2020
"context"
2121
"flag"
22+
"fmt"
2223
"os"
2324
"strings"
2425
"time"
@@ -189,9 +190,10 @@ func run(healthCheck *metrics.HealthCheck, commonFlag *common.CommonFlags) {
189190

190191
factory.Start(stopCh)
191192
informerMap := factory.WaitForCacheSync(stopCh)
192-
for informerType, synced := range informerMap {
193+
for kind, synced := range informerMap {
193194
if !synced {
194-
klog.V(0).InfoS("Initial sync failed", "kind", informerType)
195+
klog.ErrorS(nil, fmt.Sprintf("Could not sync cache for the %s informer", kind.String()))
196+
klog.FlushAndExit(klog.ExitFlushTimeout, 1)
195197
}
196198
}
197199

0 commit comments

Comments
 (0)