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 <ndevos@redhat.com>
This commit is contained in:
Niels de Vos 2020-10-26 14:18:48 +01:00 committed by mergify[bot]
parent 3e305970df
commit 4c91f07c78

View File

@ -205,7 +205,7 @@ func validateMaxSnaphostFlag(conf *util.Config) {
// [1] https://github.com/torvalds/linux/blob/master/drivers/block/rbd.c#L98 // [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 // [2] https://github.com/torvalds/linux/blob/master/drivers/block/rbd.c#L92
if conf.MaxSnapshotsOnImage == 0 || conf.MaxSnapshotsOnImage > 500 { 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")
} }
} }