Skip to content

Commit

Permalink
Update schema and fix memory limit parsing
Browse files Browse the repository at this point in the history
Signed-off-by: aiordache <anca.iordache@docker.com>
  • Loading branch information
aiordache authored and ulyssessouza committed Aug 17, 2020
1 parent d773719 commit 2b4d409
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
7 changes: 4 additions & 3 deletions compose/config/config_schema_compose_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@
"patternProperties": {"^x-": {}}
},
"mac_address": {"type": "string"},
"mem_limit": {"type": ["number", "string"]},
"mem_limit": {"type": "string"},
"mem_reservation": {"type": ["string", "integer"]},
"mem_swappiness": {"type": "integer"},
"memswap_limit": {"type": ["number", "string"]},
Expand Down Expand Up @@ -503,7 +503,7 @@
"limits": {
"type": "object",
"properties": {
"cpus": {"type": "string"},
"cpus": {"type": "number", "minimum": 0},
"memory": {"type": "string"}
},
"additionalProperties": false,
Expand All @@ -512,7 +512,7 @@
"reservations": {
"type": "object",
"properties": {
"cpus": {"type": "string"},
"cpus": {"type": "number", "minimum": 0},
"memory": {"type": "string"},
"generic_resources": {"$ref": "#/definitions/generic_resources"}
},
Expand Down Expand Up @@ -633,6 +633,7 @@
"patternProperties": {"^x-": {}}
},
"internal": {"type": "boolean"},
"enable_ipv6": {"type": "boolean"},
"attachable": {"type": "boolean"},
"labels": {"$ref": "#/definitions/list_or_dict"}
},
Expand Down
1 change: 1 addition & 0 deletions compose/config/interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ class ConversionMap:
service_path('healthcheck', 'disable'): to_boolean,
service_path('deploy', 'labels', PATH_JOKER): to_str,
service_path('deploy', 'replicas'): to_int,
service_path('deploy', 'resources', 'limits', "cpus"): to_float,
service_path('deploy', 'update_config', 'parallelism'): to_int,
service_path('deploy', 'update_config', 'max_failure_ratio'): to_float,
service_path('deploy', 'rollback_config', 'parallelism'): to_int,
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ certifi==2020.6.20
chardet==3.0.4
colorama==0.4.3; sys_platform == 'win32'
distro==1.5.0
docker==4.3.0
docker-pycreds==0.4.0
dockerpty==0.4.1
docopt==0.6.2
# temporary fix for the mem_limit float parsing
git+git://github.com/docker/docker-py@2c522fb362247a692c0493f0b47a33988eb2f3e3#egg=docker
idna==2.10
ipaddress==1.0.23
jsonschema==3.2.0
Expand Down
4 changes: 2 additions & 2 deletions tests/acceptance/cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,11 +525,11 @@ def test_config_v3(self):
},
'resources': {
'limits': {
'cpus': '0.05',
'cpus': 0.05,
'memory': '50M',
},
'reservations': {
'cpus': '0.01',
'cpus': 0.01,
'memory': '20M',
},
},
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/v3-full/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ services:
max_failure_ratio: 0.3
resources:
limits:
cpus: '0.05'
cpus: 0.05
memory: 50M
reservations:
cpus: '0.01'
cpus: 0.01
memory: 20M
restart_policy:
condition: on-failure
Expand Down

0 comments on commit 2b4d409

Please sign in to comment.