mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Correct issue with docker api 1.19 due to move of mem parameters to host_config object
This commit is contained in:
parent
809a47f299
commit
9f7ccc6645
@ -660,25 +660,47 @@ def create_container(image,
|
|||||||
volumes.remove(volume)
|
volumes.remove(volume)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
container_info = client.create_container(
|
if float(client.version()['ApiVersion']) > 1.18:
|
||||||
image=image,
|
container_info = client.create_container(
|
||||||
command=command,
|
image=image,
|
||||||
hostname=hostname,
|
command=command,
|
||||||
user=user,
|
hostname=hostname,
|
||||||
detach=detach,
|
user=user,
|
||||||
stdin_open=stdin_open,
|
detach=detach,
|
||||||
tty=tty,
|
stdin_open=stdin_open,
|
||||||
mem_limit=mem_limit,
|
tty=tty,
|
||||||
ports=ports,
|
ports=ports,
|
||||||
environment=environment,
|
environment=environment,
|
||||||
dns=dns,
|
dns=dns,
|
||||||
volumes=volumes,
|
volumes=volumes,
|
||||||
volumes_from=volumes_from,
|
volumes_from=volumes_from,
|
||||||
name=name,
|
name=name,
|
||||||
cpu_shares=cpu_shares,
|
cpu_shares=cpu_shares,
|
||||||
cpuset=cpuset,
|
cpuset=cpuset,
|
||||||
host_config=docker.utils.create_host_config(binds=binds)
|
host_config=docker.utils.create_host_config(binds=binds,
|
||||||
)
|
mem_limit=mem_limit)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
container_info = client.create_container(
|
||||||
|
image=image,
|
||||||
|
command=command,
|
||||||
|
hostname=hostname,
|
||||||
|
user=user,
|
||||||
|
detach=detach,
|
||||||
|
stdin_open=stdin_open,
|
||||||
|
tty=tty,
|
||||||
|
mem_limit=mem_limit,
|
||||||
|
ports=ports,
|
||||||
|
environment=environment,
|
||||||
|
dns=dns,
|
||||||
|
volumes=volumes,
|
||||||
|
volumes_from=volumes_from,
|
||||||
|
name=name,
|
||||||
|
cpu_shares=cpu_shares,
|
||||||
|
cpuset=cpuset,
|
||||||
|
host_config=docker.utils.create_host_config(binds=binds)
|
||||||
|
)
|
||||||
|
|
||||||
log.trace("docker.client.create_container returned: " + str(container_info))
|
log.trace("docker.client.create_container returned: " + str(container_info))
|
||||||
container = container_info['Id']
|
container = container_info['Id']
|
||||||
callback = _valid
|
callback = _valid
|
||||||
|
@ -2658,6 +2658,14 @@ def create(image,
|
|||||||
if 'api_name' in val:
|
if 'api_name' in val:
|
||||||
create_kwargs[val['api_name']] = create_kwargs.pop(key)
|
create_kwargs[val['api_name']] = create_kwargs.pop(key)
|
||||||
|
|
||||||
|
# Added to manage api change in 1.19.
|
||||||
|
# mem_limit and memswap_limit must be provided in host_config object
|
||||||
|
if float(version()['ApiVersion']) > 1.18:
|
||||||
|
create_kwargs['host_config'] = docker.utils.create_host_config(mem_limit=create_kwargs.get('mem_limit'),
|
||||||
|
memswap_limit=create_kwargs.get('memswap_limit'))
|
||||||
|
if 'mem_limit' in create_kwargs: del create_kwargs['mem_limit']
|
||||||
|
if 'memswap_limit' in create_kwargs: del create_kwargs['memswap_limit']
|
||||||
|
|
||||||
log.debug(
|
log.debug(
|
||||||
'dockerng.create is using the following kwargs to create '
|
'dockerng.create is using the following kwargs to create '
|
||||||
'container \'{0}\' from image \'{1}\': {2}'
|
'container \'{0}\' from image \'{1}\': {2}'
|
||||||
|
Loading…
Reference in New Issue
Block a user