diff options
author | Bryn M. Reeves <bmr@redhat.com> | 2017-03-27 18:23:04 +0100 |
---|---|---|
committer | Bryn M. Reeves <bmr@redhat.com> | 2017-03-27 18:23:04 +0100 |
commit | 3a3aef8a1410e6f94dee8aaa43d80934033d7589 (patch) | |
tree | 803f500a6800fd32337a3ba66eba57fbf688da16 | |
parent | 922ea54bf4f9cb488f72a75a180e5351169dd710 (diff) | |
download | sos-3a3aef8a1410e6f94dee8aaa43d80934033d7589.tar.gz |
[corosync] fix corosync.conf handling.
Don't try to open corosync.conf if it doesn't exist, and handle
exceptions on open and IO if it does.
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r-- | sos/plugins/corosync.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/sos/plugins/corosync.py b/sos/plugins/corosync.py index ee8504ce..90f73e85 100644 --- a/sos/plugins/corosync.py +++ b/sos/plugins/corosync.py @@ -13,6 +13,7 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. from sos.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin +import os.path import re @@ -41,16 +42,23 @@ class Corosync(Plugin): ]) self.call_ext_prog("killall -USR2 corosync") + corosync_conf = "/etc/corosync/corosync.conf" + if not os.path.exists(corosync_conf): + return + # collect user-defined logfiles, matching either of pattern: # log_size: filename # or # logging.log_size: filename # (it isnt precise but sufficient) pattern = '^\s*(logging.)?logfile:\s*(\S+)$' - with open("/etc/corosync/corosync.conf") as f: - for line in f: - if re.match(pattern, line): - self.add_copy_spec(re.search(pattern, line).group(2)) + try: + with open("/etc/corosync/corosync.conf") as f: + for line in f: + if re.match(pattern, line): + self.add_copy_spec(re.search(pattern, line).group(2)) + except IOError as e: + self._log_warn("could not read from %s: %s", corosync_conf, e) def postproc(self): self.do_cmd_output_sub( |