From: Michael Fritch Date: Tue, 26 Nov 2019 02:29:26 +0000 (-0700) Subject: ceph-daemon: fix `systemctl is-enabled` bool X-Git-Tag: v15.1.0~732^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F31870%2Fhead;p=ceph.git ceph-daemon: fix `systemctl is-enabled` bool systemd run-time units were not correctly detected as `enabled` Signed-off-by: Michael Fritch --- diff --git a/src/ceph-daemon/ceph-daemon b/src/ceph-daemon/ceph-daemon index 380c144cadd6..80a22183294a 100755 --- a/src/ceph-daemon/ceph-daemon +++ b/src/ceph-daemon/ceph-daemon @@ -300,10 +300,12 @@ 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). + enabled = False try: out, err, code = call(['systemctl', 'is-enabled', unit_name], verbose_on_failure=False) - enabled = out.strip() == 'enabled' + if code == 0: + enabled = True except Exception as e: logger.warning('unable to run systemctl: %s' % e) enabled = False