Skip to content

Commit 26753c8

Browse files
ercildounemilas
andauthored
api: add rollback_config to service create (#2917)
`rollback_config` was not in the list of `CREATE_SERVICE_KWARGS` which prevented it from being an argument when creating services. It has now been added and the problem fixed, allowing services to have a rollback_config during creation and updating. Fixes #2832. Signed-off-by: Fraser Patten <pattenf00@gmail.com> Signed-off-by: Milas Bowman <milas.bowman@docker.com> Co-authored-by: Milas Bowman <milas.bowman@docker.com>
1 parent 0031ac2 commit 26753c8

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

docker/models/services.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ def list(self, **kwargs):
320320
'labels',
321321
'mode',
322322
'update_config',
323+
'rollback_config',
323324
'endpoint_spec',
324325
]
325326

tests/integration/models_services_test.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,18 @@ def test_create(self):
3030
# ContainerSpec arguments
3131
image="alpine",
3232
command="sleep 300",
33-
container_labels={'container': 'label'}
33+
container_labels={'container': 'label'},
34+
rollback_config={'order': 'start-first'}
3435
)
3536
assert service.name == name
3637
assert service.attrs['Spec']['Labels']['foo'] == 'bar'
3738
container_spec = service.attrs['Spec']['TaskTemplate']['ContainerSpec']
3839
assert "alpine" in container_spec['Image']
3940
assert container_spec['Labels'] == {'container': 'label'}
41+
spec_rollback = service.attrs['Spec'].get('RollbackConfig', None)
42+
assert spec_rollback is not None
43+
assert ('Order' in spec_rollback and
44+
spec_rollback['Order'] == 'start-first')
4045

4146
def test_create_with_network(self):
4247
client = docker.from_env(version=TEST_API_VERSION)

tests/unit/models_services_test.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ def test_get_create_service_kwargs(self):
1111
'labels': {'key': 'value'},
1212
'hostname': 'test_host',
1313
'mode': 'global',
14+
'rollback_config': {'rollback': 'config'},
1415
'update_config': {'update': 'config'},
1516
'networks': ['somenet'],
1617
'endpoint_spec': {'blah': 'blah'},
@@ -37,6 +38,7 @@ def test_get_create_service_kwargs(self):
3738
'name': 'somename',
3839
'labels': {'key': 'value'},
3940
'mode': 'global',
41+
'rollback_config': {'rollback': 'config'},
4042
'update_config': {'update': 'config'},
4143
'endpoint_spec': {'blah': 'blah'},
4244
}

0 commit comments

Comments
 (0)