mirror of https://github.com/docker/docker-py.git
Merge 949446e1ff
into db7f8b8bb6
This commit is contained in:
commit
1d5a9393df
|
@ -1249,9 +1249,9 @@ class ContainerApiMixin:
|
|||
@utils.check_resource('container')
|
||||
def update_container(
|
||||
self, container, blkio_weight=None, cpu_period=None, cpu_quota=None,
|
||||
cpu_shares=None, cpuset_cpus=None, cpuset_mems=None, mem_limit=None,
|
||||
mem_reservation=None, memswap_limit=None, kernel_memory=None,
|
||||
restart_policy=None
|
||||
cpu_shares=None, nano_cpus=None, cpuset_cpus=None, cpuset_mems=None,
|
||||
mem_limit=None, mem_reservation=None, memswap_limit=None,
|
||||
kernel_memory=None, restart_policy=None
|
||||
):
|
||||
"""
|
||||
Update resource configs of one or more containers.
|
||||
|
@ -1262,6 +1262,7 @@ class ContainerApiMixin:
|
|||
cpu_period (int): Limit CPU CFS (Completely Fair Scheduler) period
|
||||
cpu_quota (int): Limit CPU CFS (Completely Fair Scheduler) quota
|
||||
cpu_shares (int): CPU shares (relative weight)
|
||||
nano_cpus (int): Number of CPUs
|
||||
cpuset_cpus (str): CPUs in which to allow execution
|
||||
cpuset_mems (str): MEMs in which to allow execution
|
||||
mem_limit (float or str): Memory limit
|
||||
|
@ -1292,6 +1293,13 @@ class ContainerApiMixin:
|
|||
data['CpusetCpus'] = cpuset_cpus
|
||||
if cpuset_mems:
|
||||
data['CpusetMems'] = cpuset_mems
|
||||
if nano_cpus:
|
||||
if utils.version_lt(self._version, '1.29'):
|
||||
raise errors.InvalidVersion(
|
||||
'Setting NanoCPUs is not supported '
|
||||
'for API version < 1.29'
|
||||
)
|
||||
data['NanoCPUs'] = nano_cpus
|
||||
if mem_limit:
|
||||
data['Memory'] = utils.parse_bytes(mem_limit)
|
||||
if mem_reservation:
|
||||
|
|
|
@ -487,6 +487,7 @@ class Container(Model):
|
|||
cpu_period (int): Limit CPU CFS (Completely Fair Scheduler) period
|
||||
cpu_quota (int): Limit CPU CFS (Completely Fair Scheduler) quota
|
||||
cpu_shares (int): CPU shares (relative weight)
|
||||
nano_cpus (int): Number of CPUs
|
||||
cpuset_cpus (str): CPUs in which to allow execution
|
||||
cpuset_mems (str): MEMs in which to allow execution
|
||||
mem_limit (int or str): Memory limit
|
||||
|
|
|
@ -1583,12 +1583,13 @@ class ContainerTest(BaseAPIClientTest):
|
|||
def test_container_update(self):
|
||||
self.client.update_container(
|
||||
fake_api.FAKE_CONTAINER_ID, mem_limit='2k', cpu_shares=124,
|
||||
blkio_weight=345
|
||||
blkio_weight=345, nano_cpus=2
|
||||
)
|
||||
args = fake_request.call_args
|
||||
assert args[0][1] == (url_prefix + 'containers/' +
|
||||
fake_api.FAKE_CONTAINER_ID + '/update')
|
||||
assert json.loads(args[1]['data']) == {
|
||||
'Memory': 2 * 1024, 'CpuShares': 124, 'BlkioWeight': 345
|
||||
'Memory': 2 * 1024, 'CpuShares': 124, 'BlkioWeight': 345,
|
||||
'NanoCPUs': 2
|
||||
}
|
||||
assert args[1]['headers']['Content-Type'] == 'application/json'
|
||||
|
|
Loading…
Reference in New Issue