From: Sage Weil Date: Fri, 25 Oct 2019 21:46:09 +0000 (-0500) Subject: ceph-daemon: tolerate systemctl is-* exit codes X-Git-Tag: v15.1.0~1156^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=24f55ba8325dd93a03274bbf437e267663119d43;p=ceph.git ceph-daemon: tolerate systemctl is-* exit codes Signed-off-by: Sage Weil --- diff --git a/src/ceph-daemon b/src/ceph-daemon index 6dfc456c0047..32c594a3164c 100755 --- a/src/ceph-daemon +++ b/src/ceph-daemon @@ -208,18 +208,17 @@ def get_unit_name(fsid, daemon_type, daemon_id): return 'ceph-%s@%s.%s' % (fsid, daemon_type, daemon_id) def check_unit(unit_name): + # NOTE: we ignore the exit code here because systemctl outputs + # various exit codes based on the state of the service, but the + # string result is more explicit (and sufficient). try: out, err, code = call(['systemctl', 'is-enabled', unit_name], 'systemctl') - if code: - raise RuntimeError('exited with %d' % code) enabled = out.strip() == 'enabled' except Exception as e: logger.warning('unable to run systemctl: %s' % e) enabled = False try: out, err, code = call(['systemctl', 'is-active', unit_name], 'systemctl') - if code: - raise RuntimeError('exited with %d' % code) active = out.strip() == 'active' except Exception as e: logger.warning('unable to run systemctl: %s' % e)