]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/influx: handle ValueError when setting options 39610/head
authorKefu Chai <kchai@redhat.com>
Mon, 22 Feb 2021 05:51:20 +0000 (13:51 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 22 Feb 2021 12:51:11 +0000 (20:51 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/pybind/mgr/influx/module.py

index e54ca1f00244caa382c77272e2d63ed89fa68661..bcc82e1b9605181f452025e5b9e2511af9d86af7 100644 (file)
@@ -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', ''