Add container state check in kolla_docker
Missing container status check in recreate_or_restart_container, this causes if the container is not running (kolla-ansible stop), to not be started with deploy/reconfigure/upgrade if any other param changes. Change-Id: I5cff5f367e963ba8b1807ec46469da817e40e468 Closes-Bug: #1714015
This commit is contained in:
parent
02fa35dc8e
commit
448a10df6c
@ -163,6 +163,15 @@ options:
|
||||
- Name or id of container(s) to use volumes from
|
||||
required: True
|
||||
type: list
|
||||
state:
|
||||
description:
|
||||
- Check container status
|
||||
required: False
|
||||
type: str
|
||||
choices:
|
||||
- running
|
||||
- exited
|
||||
- paused
|
||||
author: Sam Yaple
|
||||
'''
|
||||
|
||||
@ -291,7 +300,8 @@ class DockerWorker(object):
|
||||
self.compare_pid_mode(container_info) or
|
||||
self.compare_volumes(container_info) or
|
||||
self.compare_volumes_from(container_info) or
|
||||
self.compare_environment(container_info)
|
||||
self.compare_environment(container_info) or
|
||||
self.compare_container_state(container_info)
|
||||
)
|
||||
|
||||
def compare_ipc_mode(self, container_info):
|
||||
@ -420,6 +430,12 @@ class DockerWorker(object):
|
||||
if current_env[k] != v:
|
||||
return True
|
||||
|
||||
def compare_container_state(self, container_info):
|
||||
new_state = self.params.get('state')
|
||||
current_state = container_info['State'].get('Status')
|
||||
if new_state != current_state:
|
||||
return True
|
||||
|
||||
def parse_image(self):
|
||||
full_image = self.params.get('image')
|
||||
|
||||
@ -738,6 +754,10 @@ def generate_module():
|
||||
'always',
|
||||
'unless-stopped']),
|
||||
restart_retries=dict(required=False, type='int', default=10),
|
||||
state=dict(required=False, type='str', default='running',
|
||||
choices=['running',
|
||||
'exited',
|
||||
'paused']),
|
||||
tls_verify=dict(required=False, type='bool', default=False),
|
||||
tls_cert=dict(required=False, type='str'),
|
||||
tls_key=dict(required=False, type='str'),
|
||||
|
@ -71,6 +71,10 @@ class ModuleArgsTest(base.BaseTestCase):
|
||||
'always',
|
||||
'unless-stopped']),
|
||||
restart_retries=dict(required=False, type='int', default=10),
|
||||
state=dict(required=False, type='str', default='running',
|
||||
choices=['running',
|
||||
'exited',
|
||||
'paused']),
|
||||
tls_verify=dict(required=False, type='bool', default=False),
|
||||
tls_cert=dict(required=False, type='str'),
|
||||
tls_key=dict(required=False, type='str'),
|
||||
@ -772,3 +776,13 @@ class TestAttrComp(base.BaseTestCase):
|
||||
KOLLA_INSTALL_TYPE='binary')})
|
||||
|
||||
self.assertTrue(self.dw.compare_environment(container_info))
|
||||
|
||||
def test_compare_container_state_neg(self):
|
||||
container_info = {'State': dict(Status='running')}
|
||||
self.dw = get_DockerWorker({'state': 'running'})
|
||||
self.assertFalse(self.dw.compare_container_state(container_info))
|
||||
|
||||
def test_compare_container_state_pos(self):
|
||||
container_info = {'State': dict(Status='running')}
|
||||
self.dw = get_DockerWorker({'state': 'exited'})
|
||||
self.assertTrue(self.dw.compare_container_state(container_info))
|
||||
|
Loading…
Reference in New Issue
Block a user