Changed docker_restart_policy to unless-stopped

Current implementation has docker_restart_policy "always" and
docker_restart_policy_retry:"10" which should be mutually exclusive.
"unless-stopped" will restart the containers on any exit state
but not start on daemon startup if container was put to stopped state before.
Closes-Bug: #1621187

Change-Id: I4d881cd123a55625121b7a9047385e9b54e2e129
This commit is contained in:
Sajauddin Mohammad 2016-09-23 02:25:23 -04:00
parent b1511a1719
commit 3f134d0f53
4 changed files with 24 additions and 18 deletions

View File

@ -72,8 +72,8 @@ docker_registry:
docker_namespace: "kolla"
docker_registry_username:
# Valid options are [ never, on-failure, always ]
docker_restart_policy: "always"
# Valid options are [ never, on-failure, always, unless-stopped ]
docker_restart_policy: "unless-stopped"
# '0' means unlimited retries
docker_restart_policy_retry: "10"

View File

@ -145,6 +145,7 @@ options:
- never
- on-failure
- always
- unless-stopped
restart_retries:
description:
- How many times to attempt a restart if restart_policy is set
@ -511,7 +512,9 @@ class DockerWorker(object):
'volumes_from': self.params.get('volumes_from')
}
if self.params.get('restart_policy') in ['on-failure', 'always']:
if self.params.get('restart_policy') in ['on-failure',
'always',
'unless-stopped']:
options['restart_policy'] = {
'Name': self.params.get('restart_policy'),
'MaximumRetryCount': self.params.get('restart_retries')
@ -674,10 +677,12 @@ def generate_module():
pid_mode=dict(required=False, type='str', choices=['host']),
privileged=dict(required=False, type='bool', default=False),
remove_on_exit=dict(required=False, type='bool', default=True),
restart_policy=dict(required=False, type='str', choices=['no',
'never',
'on-failure',
'always']),
restart_policy=dict(required=False, type='str', choices=[
'no',
'never',
'on-failure',
'always',
'unless-stopped']),
restart_retries=dict(required=False, type='int', default=10),
tls_verify=dict(required=False, type='bool', default=False),
tls_cert=dict(required=False, type='str'),

View File

@ -825,7 +825,7 @@ class KollaWorker(object):
for plugin in [match.group(0) for match in
(re.search('{}-plugin-.+'.format(image.name),
section) for section in
self.conf.list_all_sections()) if match]:
self.conf.list_all_sections()) if match]:
try:
self.conf.register_opts(
common_config.get_source_opts(),

View File

@ -73,7 +73,8 @@ class ModuleArgsTest(base.BaseTestCase):
required=False, type='str', choices=['no',
'never',
'on-failure',
'always']),
'always',
'unless-stopped']),
restart_retries=dict(required=False, type='int', default=10),
tls_verify=dict(required=False, type='bool', default=False),
tls_cert=dict(required=False, type='str'),
@ -107,7 +108,7 @@ FAKE_DATA = {
'pid_mode': '',
'privileged': False,
'volumes_from': None,
'restart_policy': 'always',
'restart_policy': 'unless-stopped',
'restart_retries': 10},
'labels': {'build-date': '2016-06-02',
'kolla_version': '2.0.1',
@ -516,14 +517,14 @@ class TestVolume(base.BaseTestCase):
self.fake_data = copy.deepcopy(FAKE_DATA)
self.volumes = {
'Volumes':
[{'Driver': u'local',
'Labels': None,
'Mountpoint': '/var/lib/docker/volumes/nova_compute/_data',
'Name': 'nova_compute'},
{'Driver': 'local',
'Labels': None,
'Mountpoint': '/var/lib/docker/volumes/mariadb/_data',
'Name': 'mariadb'}]
[{'Driver': u'local',
'Labels': None,
'Mountpoint': '/var/lib/docker/volumes/nova_compute/_data',
'Name': 'nova_compute'},
{'Driver': 'local',
'Labels': None,
'Mountpoint': '/var/lib/docker/volumes/mariadb/_data',
'Name': 'mariadb'}]
}
def test_create_volume(self):