Docker Community Forums

Share and learn in the Docker community.

Help for specifying placement preferences via sdk


(Hbhanawat) #1

While creating a service I am passing the preferences. I am specifying placement preferences in multiple ways but it always fails with an error.

Parameters to start the service:
‘image =xxx/cassandra:3.0’, “preferences =[‘spread=node.labels.launcher’]”, “cassandra1EnvList =[‘JVM_OPTS=-Xms4g -Xmx4g’, ‘CASSANDRA_BROADCAST_ADDRESS=cassandra-1’, ‘CASSANDRA_SEEDS=cassandra-1,cassandra-2’, ‘CASSANDRA_LOG_DIR=/var/log/cassandra’]”, “mode ={‘replicated’: {‘Replicas’: 1}}”, “restart_policy ={‘Delay’: 0, ‘Window’: 0, ‘MaxAttempts’: 0, ‘Condition’: ‘on-failure’}”, “mounts =[’/tmp/fluir/cassandra1/data:/var/lib/cassandra’, ‘/tmp/fluir/cassandra1/logs:/var/log/cassandra’]”, ‘networks =mynet’)

I get the following error:
Traceback (most recent call last):
File “/usr/lib/python2.7/runpy.py”, line 174, in _run_module_as_main
main”, fname, loader, pkg_name)
File “/usr/lib/python2.7/runpy.py”, line 72, in _run_code
exec code in run_globals
File “/drive/repos/spark-jobserver/deployment/fluirpy/startup/cassandra.py”, line 25, in
cassandraLauncher.startCassandraService(client, config)
File “plugins/cassandra.py”, line 39, in startCassandraService
networks=[cassandraConfig.networkName], name=self.cassandra1service)
File “/usr/local/lib/python2.7/dist-packages/docker/models/services.py”, line 219, in create
service_id = self.client.api.create_service(**create_kwargs)
File “/usr/local/lib/python2.7/dist-packages/docker/utils/decorators.py”, line 34, in wrapper
return f(self, *args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/docker/api/service.py”, line 185, in create_service
self._post_json(url, data=data, headers=headers), True
File “/usr/local/lib/python2.7/dist-packages/docker/api/client.py”, line 235, in _result
self._raise_for_status(response)
File “/usr/local/lib/python2.7/dist-packages/docker/api/client.py”, line 231, in _raise_for_status
raise create_api_error_from_http_exception(e)
File “/usr/local/lib/python2.7/dist-packages/docker/errors.py”, line 31, in create_api_error_from_http_exception
raise cls(e, response=response, explanation=explanation)
docker.errors.APIError: 500 Server Error: Internal Server Error (“json: cannot unmarshal string into Go struct field Placement.Preferences of type swarm.PlacementPreference”)

I am not sure what is the right format of the placement preference. Google was of no help. Any help is appreciated. Thanks in advance