From: Kefu Chai Date: Mon, 22 Feb 2021 05:51:20 +0000 (+0800) Subject: mgr/influx: handle ValueError when setting options X-Git-Tag: v17.1.0~2843^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F39610%2Fhead;p=ceph.git mgr/influx: handle ValueError when setting options Signed-off-by: Kefu Chai --- diff --git a/src/pybind/mgr/influx/module.py b/src/pybind/mgr/influx/module.py index e54ca1f00244..bcc82e1b9605 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', ''