cleanup: do not panic when validateCloneDepthFlag() detects an error

When the cephcsi executable receives an error when calling
validateCloneDepthFlag(), it panics due to klog.Fatalln(). The errors
that validateCloneDepthFlag() 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 86a8d29bd1
commit 3e305970df

View File

@ -191,11 +191,11 @@ func main() {
func validateCloneDepthFlag(conf *util.Config) {
// keeping hardlimit to 14 as max to avoid max image depth
if conf.RbdHardMaxCloneDepth == 0 || conf.RbdHardMaxCloneDepth > 14 {
klog.Fatalln("rbdhardmaxclonedepth flag value should be between 1 and 14")
logAndExit("rbdhardmaxclonedepth flag value should be between 1 and 14")
}
if conf.RbdSoftMaxCloneDepth > conf.RbdHardMaxCloneDepth {
klog.Fatalln("rbdsoftmaxclonedepth flag value should not be greater than rbdhardmaxclonedepth")
logAndExit("rbdsoftmaxclonedepth flag value should not be greater than rbdhardmaxclonedepth")
}
}