common-tasks: Container Start/Stop conditions

The container start/stop conditions for lxc can fail if a container is
slow to start/stop which may result in an retry and fail due to the
confused state. This change checks the stdout of the command which will
report if the container is already started or stopped which should
ensure we're not failing a playbook run simply because of a container
is slow to respond to a command or in an otherwise confused state.

This issue is often seen on the cent gates:
http://logs.openstack.org/47/552047/23/check/openstack-ansible-deploy-aio_basekit-centos-7/222e1b2/job-output.txt.gz#_2018-03-15_01_45_14_559041

Change-Id: Ic52c1d00592fb194889a3aef695075c3e102fc4c
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
Kevin Carter
2018-03-14 18:18:46 -05:00
parent c8217899b2
commit b6119e6d2f

View File

@@ -103,6 +103,8 @@
# Due to https://github.com/ansible/ansible-modules-extras/issues/2691
# this uses the LXC CLI tools to ensure that we get logging.
# TODO(odyssey4me): revisit this once the bug is fixed and released
# NOTE(cloudnull): The `lxc-stop` command will have an RC of 2 if the command
# fails due to a container already being in a stopped state.
- name: Lxc container restart
command: >
lxc-stop --name {{ inventory_hostname }}
@@ -112,6 +114,8 @@
register: container_stop
until: container_stop | success
retries: 3
failed_when:
- container_stop.rc not in [0, 2]
when:
- lxc_container_allow_restarts | default(True) | bool
- not is_metal | bool