From ae56ea578fe6f7443d2dce73e2b8fcf2bd5542d1 Mon Sep 17 00:00:00 2001 From: Pavel Moravec Date: Tue, 5 Dec 2017 12:44:42 +0100 Subject: [etcd] dont traceback when etcd package isnt installed catch exception when etcd package isnt installed and we inspect its version Resolves: #1159 Signed-off-by: Pavel Moravec --- sos/plugins/etcd.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/sos/plugins/etcd.py b/sos/plugins/etcd.py index bd5d10d8..d80bbeeb 100644 --- a/sos/plugins/etcd.py +++ b/sos/plugins/etcd.py @@ -61,11 +61,16 @@ class etcd(Plugin, RedHatPlugin): return line.split('=')[1].replace('"', '').strip() # If we can't read etcd.conf, assume defaults by etcd version except: - ver = self.policy().package_manager.get_pkg_list()['etcd'] - ver = ver['version'][0] - if ver == '2': - return 'http://localhost:4001' - if ver == '3': - return 'http://localhost:2379' + # assume v3 is the default + url = 'http://localhost:2379' + try: + ver = self.policy().package_manager.get_pkg_list()['etcd'] + ver = ver['version'][0] + if ver == '2': + url = 'http://localhost:4001' + except: + # fallback when etcd is not installed + pass + return url # vim: et ts=5 sw=4 -- cgit