From 34024c84ec8c54c63957cdbd0a73cbb2d49afe76 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Mon, 22 Feb 2021 13:51:20 +0800 Subject: [PATCH] mgr/influx: handle ValueError when setting options Signed-off-by: Kefu Chai --- src/pybind/mgr/influx/module.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/pybind/mgr/influx/module.py b/src/pybind/mgr/influx/module.py index e54ca1f00244c..bcc82e1b96051 100644 --- a/src/pybind/mgr/influx/module.py +++ b/src/pybind/mgr/influx/module.py @@ -448,9 +448,12 @@ class Module(MgrModule): return -errno.EINVAL, '', 'Value should not be empty or None' self.log.debug('Setting configuration option %s to %s', key, value) - self.set_config_option(key, value) - self.set_module_option(key, value) - return 0, 'Configuration option {0} updated'.format(key), '' + try: + self.set_module_option(key, value) + self.set_config_option(key, value) + return 0, 'Configuration option {0} updated'.format(key), '' + except ValueError as e: + return -errno.EINVAL, '', str(e) elif cmd['prefix'] == 'influx send': self.send_to_influx() return 0, 'Sending data to Influx', '' -- 2.39.5