Unfreeze frozen container before stopping

Gracefully stopping a frozen container results in a significant delay,
at least in my testing. This commit unfreezes the container before
stopping it, if the container was frozen when the stop() function is
called.
This commit is contained in:
Erik Johnson 2014-11-10 02:16:09 -06:00
parent e019e5a474
commit f777edfbec

View File

@ -1771,10 +1771,18 @@ def stop(name, kill=False):
salt myminion lxc.stop name
'''
_ensure_exists(name)
orig_state = state(name)
if orig_state == 'frozen' and not kill:
# Gracefully stopping a frozen container is slower than unfreezing and
# then stopping it (at least in my testing), so if we're not
# force-stopping the container, unfreeze it first.
unfreeze(name)
cmd = 'lxc-stop'
if kill:
cmd += ' -k'
return _change_state(cmd, name, 'stopped')
ret = _change_state(cmd, name, 'stopped')
ret['state']['old'] = orig_state
return ret
def freeze(name, **kwargs):