From 79e91fa894e561e1a187baa19967f92ffe461a80 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Mon, 26 Oct 2020 14:08:55 +0100 Subject: [PATCH] cleanup: prevent Go panic on missing driver type When running the 'cephcsi' executable without arguments, a Go panic is reported: $ ./_output/cephcsi F1026 13:59:04.302740 3409054 cephcsi.go:126] driver type not specified goroutine 1 [running]: k8s.io/klog/v2.stacks(0xc000010001, 0xc0000520a0, 0x48, 0x9a) /go/src/github.com/ceph/ceph-csi/vendor/k8s.io/klog/v2/klog.go:996 +0xb9 k8s.io/klog/v2.(*loggingT).output(0x2370360, 0xc000000003, 0x0, 0x0, 0xc000194770, 0x20cb265, 0xa, 0x7e, 0x413500) /go/src/github.com/ceph/ceph-csi/vendor/k8s.io/klog/v2/klog.go:945 +0x191 k8s.io/klog/v2.(*loggingT).println(0x2370360, 0x3, 0x0, 0x0, 0xc000163e08, 0x1, 0x1) /go/src/github.com/ceph/ceph-csi/vendor/k8s.io/klog/v2/klog.go:699 +0x11a k8s.io/klog/v2.Fatalln(...) /go/src/github.com/ceph/ceph-csi/vendor/k8s.io/klog/v2/klog.go:1456 main.main() /go/src/github.com/ceph/ceph-csi/cmd/cephcsi.go:126 +0xafa Just logging the error and exiting should be sufficient. This stack-trace from the Go panic does not add any useful information. Signed-off-by: Niels de Vos --- cmd/cephcsi.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/cephcsi.go b/cmd/cephcsi.go index 77e50f251..13896401a 100644 --- a/cmd/cephcsi.go +++ b/cmd/cephcsi.go @@ -123,7 +123,7 @@ func main() { util.DefaultLog("Driver version: %s and Git version: %s", util.DriverVersion, util.GitCommit) if conf.Vtype == "" { - klog.Fatalln("driver type not specified") + logAndExit("driver type not specified") } dname := getDriverName()