From 8e76533dab507fcb129ba4a7227062a01b8e7ccc Mon Sep 17 00:00:00 2001 From: Fabian Fuelling Date: Wed, 20 Apr 2022 18:02:23 +0200 Subject: [PATCH 1/5] Hotfix: only set "cpu" and "memory" in new task definition, if defined (not None) --- ecs_deploy/ecs.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ecs_deploy/ecs.py b/ecs_deploy/ecs.py index 0f5d70d..bd4fa14 100644 --- a/ecs_deploy/ecs.py +++ b/ecs_deploy/ecs.py @@ -86,6 +86,12 @@ def register_task_definition(self, family, containers, volumes, role_arn, if tags: additional_properties['tags'] = tags + if cpu: + additional_properties['cpu'] = cpu + + if memory: + additional_properties['memory'] = memory + return self.boto.register_task_definition( family=family, containerDefinitions=containers, @@ -93,8 +99,6 @@ def register_task_definition(self, family, containers, volumes, role_arn, taskRoleArn=role_arn, executionRoleArn=execution_role_arn, runtimePlatform=runtime_platform, - cpu=cpu, - memory=memory, **additional_properties ) From 914d07569f520c59d0ec5c499b92dc7431f5f388 Mon Sep 17 00:00:00 2001 From: Fabian Fuelling Date: Wed, 20 Apr 2022 18:04:24 +0200 Subject: [PATCH 2/5] Only set "runtimePlatform" in new task definition, if defined (not None) --- ecs_deploy/ecs.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ecs_deploy/ecs.py b/ecs_deploy/ecs.py index bd4fa14..bc0dd77 100644 --- a/ecs_deploy/ecs.py +++ b/ecs_deploy/ecs.py @@ -92,13 +92,15 @@ def register_task_definition(self, family, containers, volumes, role_arn, if memory: additional_properties['memory'] = memory + if runtimePlatform: + additional_properties['runtimePlatform'] = runtimePlatform + return self.boto.register_task_definition( family=family, containerDefinitions=containers, volumes=volumes, taskRoleArn=role_arn, executionRoleArn=execution_role_arn, - runtimePlatform=runtime_platform, **additional_properties ) From 762c8364625f60654158935fa0157eb2d7ad15eb Mon Sep 17 00:00:00 2001 From: Fabian Fuelling Date: Wed, 20 Apr 2022 18:05:37 +0200 Subject: [PATCH 3/5] Fix var name runtime_platform --- ecs_deploy/ecs.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ecs_deploy/ecs.py b/ecs_deploy/ecs.py index bc0dd77..3c0bd65 100644 --- a/ecs_deploy/ecs.py +++ b/ecs_deploy/ecs.py @@ -92,8 +92,8 @@ def register_task_definition(self, family, containers, volumes, role_arn, if memory: additional_properties['memory'] = memory - if runtimePlatform: - additional_properties['runtimePlatform'] = runtimePlatform + if runtime_platform: + additional_properties['runtimePlatform'] = runtime_platform return self.boto.register_task_definition( family=family, From 5bbcdacbd8c3b095051fdbb43e8be38b5768a4db Mon Sep 17 00:00:00 2001 From: Fabian Fuelling Date: Wed, 20 Apr 2022 18:11:08 +0200 Subject: [PATCH 4/5] Add test to ensure, optional parameters are not sent, if None --- tests/test_ecs.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/tests/test_ecs.py b/tests/test_ecs.py index ab6a22a..83cdd8c 100644 --- a/tests/test_ecs.py +++ b/tests/test_ecs.py @@ -1147,6 +1147,50 @@ def test_client_register_task_definition(client): ) +def test_client_register_task_definition_without_optional_values(client): + containers = [{u'name': u'foo'}] + volumes = [{u'foo': u'bar'}] + role_arn = 'arn:test:role' + execution_role_arn = 'arn:test:role' + runtime_platform = {u'cpuArchitecture': u'X86_64', u'operatingSystemFamily': u'LINUX'} + task_definition = EcsTaskDefinition( + containerDefinitions=containers, + volumes=volumes, + family=u'family', + revision=1, + taskRoleArn=role_arn, + executionRoleArn=execution_role_arn, + tags={ + 'Name': 'test_client_register_task_definition' + }, + status='active', + taskDefinitionArn='arn:task', + requiresAttributes={}, + ) + + client.register_task_definition( + family=task_definition.family, + containers=task_definition.containers, + volumes=task_definition.volumes, + role_arn=task_definition.role_arn, + execution_role_arn=execution_role_arn, + tags=task_definition.tags, + additional_properties=task_definition.additional_properties, + runtime_platform=None, + cpu=None, + memory=None + ) + + client.boto.register_task_definition.assert_called_once_with( + family=u'family', + containerDefinitions=containers, + volumes=volumes, + taskRoleArn=role_arn, + executionRoleArn=execution_role_arn, + tags=task_definition.tags, + ) + + def test_client_register_task_definition_without_tags(client): containers = [{u'name': u'foo'}] volumes = [{u'foo': u'bar'}] From 567d087f5fa7d9468a5fe9953b59b4efbbc2a2b8 Mon Sep 17 00:00:00 2001 From: Fabian Fuelling Date: Wed, 20 Apr 2022 18:13:02 +0200 Subject: [PATCH 5/5] Bump version to 1.13.1 --- ecs_deploy/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ecs_deploy/__init__.py b/ecs_deploy/__init__.py index 9fb1be8..0f5d860 100644 --- a/ecs_deploy/__init__.py +++ b/ecs_deploy/__init__.py @@ -1 +1 @@ -VERSION = '1.13.0' +VERSION = '1.13.1'