From 07a9683157ffe396e29ba81b2e46741971f14035 Mon Sep 17 00:00:00 2001 From: Floris-Andrei Stoica-Marcu Date: Sat, 19 Sep 2020 23:09:19 +0300 Subject: [PATCH 1/2] changed resource.limits.cpus conversion to str to be compatible with docker stack deploy Signed-off-by: Floris-Andrei Stoica-Marcu --- compose/config/interpolation.py | 2 +- tests/acceptance/cli_test.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/compose/config/interpolation.py b/compose/config/interpolation.py index 832344e2c2b..1f116bea1ef 100644 --- a/compose/config/interpolation.py +++ b/compose/config/interpolation.py @@ -241,7 +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', 'resources', 'limits', "cpus"): to_str, 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, diff --git a/tests/acceptance/cli_test.py b/tests/acceptance/cli_test.py index 3d9a31c2dc7..eabd8568d96 100644 --- a/tests/acceptance/cli_test.py +++ b/tests/acceptance/cli_test.py @@ -525,7 +525,7 @@ def test_config_v3(self): }, 'resources': { 'limits': { - 'cpus': 0.05, + 'cpus': '0.05', 'memory': '50M', }, 'reservations': { From 948cea5cd28b9ff34f829a4bbf20705d777bc763 Mon Sep 17 00:00:00 2001 From: Floris-Andrei Stoica-Marcu Date: Sun, 20 Sep 2020 02:49:25 +0300 Subject: [PATCH 2/2] fixed resource.reservations.cpus to match what docker stack deploy uses Signed-off-by: Floris-Andrei Stoica-Marcu --- compose/config/interpolation.py | 1 + tests/acceptance/cli_test.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/compose/config/interpolation.py b/compose/config/interpolation.py index 1f116bea1ef..e714ab5838d 100644 --- a/compose/config/interpolation.py +++ b/compose/config/interpolation.py @@ -242,6 +242,7 @@ class ConversionMap: service_path('deploy', 'labels', PATH_JOKER): to_str, service_path('deploy', 'replicas'): to_int, service_path('deploy', 'resources', 'limits', "cpus"): to_str, + service_path('deploy', 'resources', 'reservations', "cpus"): to_str, 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, diff --git a/tests/acceptance/cli_test.py b/tests/acceptance/cli_test.py index eabd8568d96..fe6b8cda0c7 100644 --- a/tests/acceptance/cli_test.py +++ b/tests/acceptance/cli_test.py @@ -529,7 +529,7 @@ def test_config_v3(self): 'memory': '50M', }, 'reservations': { - 'cpus': 0.01, + 'cpus': '0.01', 'memory': '20M', }, },