Skip to content

Commit

Permalink
api: add rollback_config to service create (#2917)
Browse files Browse the repository at this point in the history
`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>
  • Loading branch information
ercildoune and milas authored Jul 29, 2022
1 parent 0031ac2 commit 26753c8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions docker/models/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ def list(self, **kwargs):
'labels',
'mode',
'update_config',
'rollback_config',
'endpoint_spec',
]

Expand Down
7 changes: 6 additions & 1 deletion tests/integration/models_services_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,18 @@ def test_create(self):
# ContainerSpec arguments
image="alpine",
command="sleep 300",
container_labels={'container': 'label'}
container_labels={'container': 'label'},
rollback_config={'order': 'start-first'}
)
assert service.name == name
assert service.attrs['Spec']['Labels']['foo'] == 'bar'
container_spec = service.attrs['Spec']['TaskTemplate']['ContainerSpec']
assert "alpine" in container_spec['Image']
assert container_spec['Labels'] == {'container': 'label'}
spec_rollback = service.attrs['Spec'].get('RollbackConfig', None)
assert spec_rollback is not None
assert ('Order' in spec_rollback and
spec_rollback['Order'] == 'start-first')

def test_create_with_network(self):
client = docker.from_env(version=TEST_API_VERSION)
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/models_services_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def test_get_create_service_kwargs(self):
'labels': {'key': 'value'},
'hostname': 'test_host',
'mode': 'global',
'rollback_config': {'rollback': 'config'},
'update_config': {'update': 'config'},
'networks': ['somenet'],
'endpoint_spec': {'blah': 'blah'},
Expand All @@ -37,6 +38,7 @@ def test_get_create_service_kwargs(self):
'name': 'somename',
'labels': {'key': 'value'},
'mode': 'global',
'rollback_config': {'rollback': 'config'},
'update_config': {'update': 'config'},
'endpoint_spec': {'blah': 'blah'},
}
Expand Down

0 comments on commit 26753c8

Please sign in to comment.