From e8a9357d941afaf9cc02ad6e8f962c26537bf19f Mon Sep 17 00:00:00 2001 From: Wido den Hollander Date: Tue, 5 Jun 2018 12:10:20 +0200 Subject: [PATCH] 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 --- src/pybind/mgr/telegraf/module.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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') -- 2.47.3