From b815a00e33166f6bd3b014d4a8a1a1a3b3a367b0 Mon Sep 17 00:00:00 2001 From: Alexey Rokhin Date: Wed, 17 May 2017 23:21:47 +0300 Subject: [PATCH] Implement review suggestions. Signed-off-by: Alexey Rokhin --- compose/config/config_schema_v2.2.json | 2 +- compose/service.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/compose/config/config_schema_v2.2.json b/compose/config/config_schema_v2.2.json index bbf312c6a..a585f2a8c 100644 --- a/compose/config/config_schema_v2.2.json +++ b/compose/config/config_schema_v2.2.json @@ -78,7 +78,7 @@ "cpu_percent": {"type": "integer", "minimum": 0, "maximum": 100}, "cpu_shares": {"type": ["number", "string"]}, "cpu_quota": {"type": ["number", "string"]}, - "cpus": {"type": ["number", "string"], "minimum": 0}, + "cpus": {"type": "number", "minimum": 0}, "cpuset": {"type": "string"}, "depends_on": { "oneOf": [ diff --git a/compose/service.py b/compose/service.py index 3956a4782..515992ad4 100644 --- a/compose/service.py +++ b/compose/service.py @@ -803,7 +803,10 @@ class Service(object): nano_cpus = None if 'cpus' in options: - nano_cpus = int(options.get('cpus') * 1000000000) + nano_cpus = options.get('cpus') * 1000000000 + if isinstance(nano_cpus, float) and not nano_cpus.is_integer(): + raise ValueError("cpus is too precise") + nano_cpus = int(nano_cpus) return self.client.create_host_config( links=self._get_links(link_to_self=one_off),