From 5a390f58d9363fdfdfe17f7a09cd276fe4a10fa7 Mon Sep 17 00:00:00 2001 From: kerthcet Date: Fri, 28 Jan 2022 10:18:54 +0800 Subject: [PATCH] bug: estimator's os.Exit will not wait for the defer function Signed-off-by: kerthcet --- cmd/scheduler-estimator/main.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/cmd/scheduler-estimator/main.go b/cmd/scheduler-estimator/main.go index 03e5da966..3ed3214b1 100644 --- a/cmd/scheduler-estimator/main.go +++ b/cmd/scheduler-estimator/main.go @@ -1,7 +1,6 @@ package main import ( - "fmt" "os" apiserver "k8s.io/apiserver/pkg/server" @@ -11,13 +10,19 @@ import ( ) func main() { + if err := runSchedulerEstimatorCmd(); err != nil { + os.Exit(1) + } +} + +func runSchedulerEstimatorCmd() error { logs.InitLogs() defer logs.FlushLogs() ctx := apiserver.SetupSignalContext() - if err := app.NewSchedulerEstimatorCommand(ctx).Execute(); err != nil { - fmt.Fprintf(os.Stderr, "%v\n", err) - os.Exit(1) + return err } + + return nil }