]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/telegraf: Catch OSError instead of errno
authorWido den Hollander <wido@42on.com>
Tue, 5 Jun 2018 10:10:20 +0000 (12:10 +0200)
committerWido den Hollander <wido@42on.com>
Fri, 15 Jun 2018 14:42:11 +0000 (16:42 +0200)
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 <wido@42on.com>
src/pybind/mgr/telegraf/module.py

index 584c38aaf2380ad141fce9aa2ca5d39944264cf0..e33d1ebf011666c82cd0a3d21c76994878460912 100644 (file)
@@ -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')