From 193ce726c242556416556869ed48c86e14b22632 Mon Sep 17 00:00:00 2001 From: wangwei Date: Tue, 6 Feb 2018 02:31:10 -0500 Subject: [PATCH] Fix ipc_mode comparison in the latest docker In old docker, if you do not specify ipc_mode, the default value is empty, but in the latest docker, such as 17.09.0, if not specified, the default is "IpcMode": "shareable", which will cause all containers to be deleted and re-create when to redeploy or upgrade. This commit solves the problem. Change-Id: Ia8269b9c8066880e4aee23d6fdea8d9c04c41e44 Closes-Bug: #1747586 --- ansible/library/kolla_docker.py | 9 +++++++-- tests/test_kolla_docker.py | 5 ++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ansible/library/kolla_docker.py b/ansible/library/kolla_docker.py index 580692c844..f736dd7bf6 100644 --- a/ansible/library/kolla_docker.py +++ b/ansible/library/kolla_docker.py @@ -310,8 +310,10 @@ class DockerWorker(object): if not current_ipc_mode: current_ipc_mode = None - if new_ipc_mode != current_ipc_mode: + # only check IPC mode if it is specified + if new_ipc_mode is not None and new_ipc_mode != current_ipc_mode: return True + return False def compare_cap_add(self, container_info): new_cap_add = self.params.get('cap_add', list()) @@ -744,7 +746,10 @@ def generate_module(): name=dict(required=False, type='str'), environment=dict(required=False, type='dict'), image=dict(required=False, type='str'), - ipc_mode=dict(required=False, type='str', choices=['host', '']), + ipc_mode=dict(required=False, type='str', choices=['', + 'host', + 'private', + 'shareable']), cap_add=dict(required=False, type='list', default=list()), security_opt=dict(required=False, type='list', default=list()), pid_mode=dict(required=False, type='str', choices=['host', '']), diff --git a/tests/test_kolla_docker.py b/tests/test_kolla_docker.py index 4179f9cb38..f0ea08fdb7 100644 --- a/tests/test_kolla_docker.py +++ b/tests/test_kolla_docker.py @@ -57,7 +57,10 @@ class ModuleArgsTest(base.BaseTestCase): name=dict(required=False, type='str'), environment=dict(required=False, type='dict'), image=dict(required=False, type='str'), - ipc_mode=dict(required=False, type='str', choices=['host', '']), + ipc_mode=dict(required=False, type='str', choices=['', + 'host', + 'private', + 'shareable']), cap_add=dict(required=False, type='list', default=list()), security_opt=dict(required=False, type='list', default=list()), pid_mode=dict(required=False, type='str', choices=['host', '']),