Merge "Make systemd.service_delete handle healthchecks"
This commit is contained in:
commit
63a8b2b06e
@ -54,10 +54,25 @@ class TestUtilsSystemd(base.TestCase):
|
|||||||
mock_isfile.return_value = True
|
mock_isfile.return_value = True
|
||||||
container = 'my_app'
|
container = 'my_app'
|
||||||
service = 'tripleo_' + container
|
service = 'tripleo_' + container
|
||||||
systemd.service_delete(container)
|
tempdir = tempfile.mkdtemp()
|
||||||
|
|
||||||
|
systemd.service_delete(container, tempdir)
|
||||||
|
mock_rm.assert_has_calls([
|
||||||
|
mock.call(tempdir + service + '.service'),
|
||||||
|
mock.call(tempdir + service + '_healthcheck.service'),
|
||||||
|
mock.call(tempdir + service + '_healthcheck.timer'),
|
||||||
|
])
|
||||||
mock_subprocess_call.assert_has_calls([
|
mock_subprocess_call.assert_has_calls([
|
||||||
mock.call(['systemctl', 'stop', service]),
|
mock.call(['systemctl', 'stop', service + '.service']),
|
||||||
mock.call(['systemctl', 'disable', service]),
|
mock.call(['systemctl', 'disable', service + '.service']),
|
||||||
|
mock.call(['systemctl', 'daemon-reload']),
|
||||||
|
mock.call(['systemctl', 'stop', service + '_healthcheck.service']),
|
||||||
|
mock.call(['systemctl', 'disable', service +
|
||||||
|
'_healthcheck.service']),
|
||||||
|
mock.call(['systemctl', 'daemon-reload']),
|
||||||
|
mock.call(['systemctl', 'stop', service + '_healthcheck.timer']),
|
||||||
|
mock.call(['systemctl', 'disable', service +
|
||||||
|
'_healthcheck.timer']),
|
||||||
mock.call(['systemctl', 'daemon-reload']),
|
mock.call(['systemctl', 'daemon-reload']),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
@ -99,16 +99,20 @@ def service_delete(container, sysdir=constants.SYSTEMD_DIR, log=None):
|
|||||||
# prefix is explained in the service_create().
|
# prefix is explained in the service_create().
|
||||||
service = 'tripleo_' + container
|
service = 'tripleo_' + container
|
||||||
|
|
||||||
sysd_unit_f = sysdir + service + '.service'
|
sysd_unit_f = service + '.service'
|
||||||
if os.path.isfile(sysd_unit_f):
|
sysd_health_f = service + '_healthcheck.service'
|
||||||
log.debug('Stopping and disabling systemd service for %s' % service)
|
sysd_timer_f = service + '_healthcheck.timer'
|
||||||
subprocess.call(['systemctl', 'stop', service])
|
for sysd_f in sysd_unit_f, sysd_health_f, sysd_timer_f:
|
||||||
subprocess.call(['systemctl', 'disable', service])
|
if os.path.isfile(sysdir + sysd_f):
|
||||||
log.debug('Removing systemd unit file %s' % sysd_unit_f)
|
log.debug('Stopping and disabling systemd service for %s' %
|
||||||
os.remove(sysd_unit_f)
|
service)
|
||||||
subprocess.call(['systemctl', 'daemon-reload'])
|
subprocess.call(['systemctl', 'stop', sysd_f])
|
||||||
else:
|
subprocess.call(['systemctl', 'disable', sysd_f])
|
||||||
log.warning('No systemd unit file was found for %s' % service)
|
log.debug('Removing systemd unit file %s' % sysd_f)
|
||||||
|
os.remove(sysdir + sysd_f)
|
||||||
|
subprocess.call(['systemctl', 'daemon-reload'])
|
||||||
|
else:
|
||||||
|
log.warning('No systemd unit file was found for %s' % sysd_f)
|
||||||
|
|
||||||
|
|
||||||
def healthcheck_create(container, sysdir='/etc/systemd/system/', log=None):
|
def healthcheck_create(container, sysdir='/etc/systemd/system/', log=None):
|
||||||
|
Loading…
Reference in New Issue
Block a user