@@ -141,7 +141,7 @@ func main() {
141141
142142 if len (commonFlags .VpaObjectNamespace ) > 0 && len (commonFlags .IgnoredVpaObjectNamespaces ) > 0 {
143143 klog .ErrorS (nil , "--vpa-object-namespace and --ignored-vpa-object-namespaces are mutually exclusive and can't be set together." )
144- os . Exit ( 255 )
144+ klog . FlushAndExit ( klog . ExitFlushTimeout , 1 )
145145 }
146146
147147 if * routines .MinCheckpointsPerRun != 10 { // Default value is 10
@@ -162,7 +162,7 @@ func main() {
162162 id , err := os .Hostname ()
163163 if err != nil {
164164 klog .ErrorS (err , "Unable to get hostname" )
165- os . Exit ( 255 )
165+ klog . FlushAndExit ( klog . ExitFlushTimeout , 1 )
166166 }
167167 id = id + "_" + string (uuid .NewUUID ())
168168
@@ -181,7 +181,7 @@ func main() {
181181 )
182182 if err != nil {
183183 klog .ErrorS (err , "Unable to create leader election lock" )
184- os . Exit ( 255 )
184+ klog . FlushAndExit ( klog . ExitFlushTimeout , 1 )
185185 }
186186
187187 leaderelection .RunOrDie (ctx , leaderelection.LeaderElectionConfig {
@@ -296,7 +296,7 @@ func run(ctx context.Context, healthCheck *metrics.HealthCheck, commonFlag *comm
296296 promQueryTimeout , err := time .ParseDuration (* queryTimeout )
297297 if err != nil {
298298 klog .ErrorS (err , "Could not parse --prometheus-query-timeout as a time.Duration" )
299- os . Exit ( 255 )
299+ klog . FlushAndExit ( klog . ExitFlushTimeout , 1 )
300300 }
301301
302302 if useCheckpoints {
@@ -324,7 +324,7 @@ func run(ctx context.Context, healthCheck *metrics.HealthCheck, commonFlag *comm
324324 provider , err := history .NewPrometheusHistoryProvider (config )
325325 if err != nil {
326326 klog .ErrorS (err , "Could not initialize history provider" )
327- os . Exit ( 255 )
327+ klog . FlushAndExit ( klog . ExitFlushTimeout , 1 )
328328 }
329329 recommender .GetClusterStateFeeder ().InitFromHistoryProvider (provider )
330330 }
0 commit comments