Skip to content

Commit dac943a

Browse files
knackaronshin-
authored andcommitted
honor placement preferences via services.create()
this allows creating a service with placement preferences when calling services.create(). only constraints were being honored before. related to #1615 Signed-off-by: Aron Parsons <[email protected]>
1 parent 29dee5a commit dac943a

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

docker/models/services.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,10 +321,15 @@ def _get_create_service_kwargs(func_name, kwargs):
321321
if 'container_labels' in kwargs:
322322
container_spec_kwargs['labels'] = kwargs.pop('container_labels')
323323

324+
placement = {}
325+
324326
if 'constraints' in kwargs:
325-
task_template_kwargs['placement'] = {
326-
'Constraints': kwargs.pop('constraints')
327-
}
327+
placement['Constraints'] = kwargs.pop('constraints')
328+
329+
if 'preferences' in kwargs:
330+
placement['Preferences'] = kwargs.pop('preferences')
331+
332+
task_template_kwargs['placement'] = placement
328333

329334
if 'log_driver' in kwargs:
330335
task_template_kwargs['log_driver'] = {

0 commit comments

Comments
 (0)