From: Wido den Hollander Date: Tue, 5 Jun 2018 10:10:20 +0000 (+0200) Subject: mgr/telegraf: Catch OSError instead of errno X-Git-Tag: v14.0.1~1004^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e8a9357d941afaf9cc02ad6e8f962c26537bf19f;p=ceph.git mgr/telegraf: Catch OSError instead of errno A OSError will be thrown (and not catched) if the module starts for the first time and the UNIX socket of the Telegraf Agent does not exist (yet). This will render the module useless because it can not accept commands for configuration at that point. If we catch an exception, simply log it but do not raise it. Signed-off-by: Wido den Hollander --- diff --git a/src/pybind/mgr/telegraf/module.py b/src/pybind/mgr/telegraf/module.py index 584c38aaf238..e33d1ebf0116 100644 --- a/src/pybind/mgr/telegraf/module.py +++ b/src/pybind/mgr/telegraf/module.py @@ -251,7 +251,7 @@ class Module(MgrModule): measurement['tags'], now) self.log.debug(line.to_line_protocol()) s.send(line.to_line_protocol()) - except (socket.error, RuntimeError, errno, IOError): + except (socket.error, RuntimeError, IOError, OSError): self.log.exception('Failed to send statistics to Telegraf:') def shutdown(self): @@ -283,7 +283,7 @@ class Module(MgrModule): "Command not found '{0}'".format(cmd['prefix'])) def self_test(self): - measurements = self.gather_measurements() + measurements = list(self.gather_measurements()) if len(measurements) == 0: raise RuntimeError('No measurements found')