Skip to content

Commit 1d31607

Browse files
authored
Merge pull request #309 from sil-org/fix-task-memory
Release 3.10.23 - Retain the `cpu` and `memory` properties at the task level
2 parents 5daaca2 + 05940dd commit 1d31607

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

ecs-deploy

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22

33
# Setup default values for variables
4-
VERSION="3.10.22"
4+
VERSION="3.10.23"
55
CLUSTER=false
66
SERVICE=false
77
TASK_DEFINITION=false
@@ -392,18 +392,17 @@ function createNewTaskDefJson() {
392392

393393
# Some options in task definition should only be included in new definition if present in
394394
# current definition. If found in current definition, append to JQ filter.
395-
CONDITIONAL_OPTIONS=(networkMode taskRoleArn placementConstraints executionRoleArn runtimePlatform ephemeralStorage proxyConfiguration)
395+
CONDITIONAL_OPTIONS=(networkMode taskRoleArn placementConstraints executionRoleArn runtimePlatform ephemeralStorage proxyConfiguration cpu memory)
396396
for i in "${CONDITIONAL_OPTIONS[@]}"; do
397-
re=".*${i}.*"
398-
if [[ "$DEF" =~ $re ]]; then
397+
if echo "$DEF" | jq --exit-status --arg key "$i" 'has($key)' >/dev/null; then
399398
NEW_DEF_JQ_FILTER="${NEW_DEF_JQ_FILTER}, ${i}: .${i}"
400399
fi
401400
done
402401

403402
# Updated jq filters for AWS Fargate
404403
REQUIRES_COMPATIBILITIES=$(echo "${DEF}" | jq -r '. | select(.requiresCompatibilities != null) | .requiresCompatibilities[]')
405404
if `echo ${REQUIRES_COMPATIBILITIES[@]} | grep -q "FARGATE"`; then
406-
FARGATE_JQ_FILTER='requiresCompatibilities: .requiresCompatibilities, cpu: .cpu, memory: .memory'
405+
FARGATE_JQ_FILTER='requiresCompatibilities: .requiresCompatibilities'
407406

408407
if [[ ! "$NEW_DEF_JQ_FILTER" =~ ".*executionRoleArn.*" ]]; then
409408
FARGATE_JQ_FILTER="${FARGATE_JQ_FILTER}, executionRoleArn: .executionRoleArn"

test.bats

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ EOF
407407
}
408408
EOF
409409
)
410-
expected='{ "family": "app-task-def", "volumes": [], "containerDefinitions": [ { "environment": [ { "name": "KEY", "value": "value" } ], "name": "API", "links": [], "mountPoints": [], "image": "121212345678.dkr.ecr.us-east-1.amazonaws.com/acct/repo:1111111111", "essential": true, "portMappings": [ { "protocol": "tcp", "containerPort": 80, "hostPort": 10080 } ], "entryPoint": [], "memory": 128, "command": [ "/data/run.sh" ], "cpu": 200, "volumesFrom": [] } ], "placementConstraints": null, "networkMode": "awsvpc", "executionRoleArn": "arn:aws:iam::121212345678:role/ecsTaskExecutionRole", "requiresCompatibilities": [ "FARGATE" ], "cpu": "256", "memory": "512" }'
410+
expected='{ "family": "app-task-def", "volumes": [], "containerDefinitions": [ { "environment": [ { "name": "KEY", "value": "value" } ], "name": "API", "links": [], "mountPoints": [], "image": "121212345678.dkr.ecr.us-east-1.amazonaws.com/acct/repo:1111111111", "essential": true, "portMappings": [ { "protocol": "tcp", "containerPort": 80, "hostPort": 10080 } ], "entryPoint": [], "memory": 128, "command": [ "/data/run.sh" ], "cpu": 200, "volumesFrom": [] } ], "placementConstraints": null, "networkMode": "awsvpc", "executionRoleArn": "arn:aws:iam::121212345678:role/ecsTaskExecutionRole", "cpu": "256", "memory": "512", "requiresCompatibilities": [ "FARGATE" ] }'
411411
run createNewTaskDefJson
412412
[ ! -z $status ]
413413
[ "$(echo "$output" | jq .)" == "$(echo "$expected" | jq .)" ]

0 commit comments

Comments
 (0)