From 4c91f07c7875aab2e33f2a5e025e06342167215a Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Mon, 26 Oct 2020 14:18:48 +0100 Subject: [PATCH] cleanup: do not panic when validateMaxSnaphostFlag() detects an error When the cephcsi executable detects an error when calling validateMaxSnaphostFlag(), it panics due to klog.Fatalln(). The error that validateMaxSnaphostFlag() logs should be understandable enough, so that users know what to investigate. A Go panic on a user error is not very userfriendly, and does not provide any additional usefil 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 d135e31a4..a55f8f8de 100644 --- a/cmd/cephcsi.go +++ b/cmd/cephcsi.go @@ -205,7 +205,7 @@ func validateMaxSnaphostFlag(conf *util.Config) { // [1] https://github.com/torvalds/linux/blob/master/drivers/block/rbd.c#L98 // [2] https://github.com/torvalds/linux/blob/master/drivers/block/rbd.c#L92 if conf.MaxSnapshotsOnImage == 0 || conf.MaxSnapshotsOnImage > 500 { - klog.Fatalln("maxsnapshotsonimage flag value should be between 1 and 500") + logAndExit("maxsnapshotsonimage flag value should be between 1 and 500") } }