From 7101a6dc8ed9cba1ee8cf6d472f5dc17c6336512 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Tue, 27 Oct 2020 08:13:30 +0100 Subject: [PATCH] cleanup: add logAndExit() for cephcsi:main() to call instead of panic The main() function of the cephcsi executable calls klog.Fatalln() to report certain errors. This causes the executable to panic which is not helpful to users that only need the error message. By introducing logAndExit(), there is no need to call klog.Fatalln() anymore. Signed-off-by: Niels de Vos --- cmd/cephcsi.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/cephcsi.go b/cmd/cephcsi.go index eaf386c9b..77e50f251 100644 --- a/cmd/cephcsi.go +++ b/cmd/cephcsi.go @@ -208,3 +208,8 @@ func validateMaxSnaphostFlag(conf *util.Config) { klog.Fatalln("maxsnapshotsonimage flag value should be between 1 and 500") } } + +func logAndExit(msg string) { + klog.Errorln(msg) + os.Exit(1) +}