aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.41k stars 3.8k forks source link

ECS: Memory reservation is not optional #20785

Open parisholley opened 2 years ago

parisholley commented 2 years ago

Describe the bug

task memory config is required in CDK but not supported by windows instances

https://github.com/aws/aws-cdk/blob/ddb4766785e27fbd4d672a5ff31fb07c3d3d389a/packages/%40aws-cdk/aws-ecs/lib/base/task-definition.ts#L682-L695

Expected Behavior

should allow it to be undefined

Current Behavior

throws exception

Reproduction Steps

leave out memory keys

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

latest

Framework Version

No response

Node.js Version

16

OS

mac

Language

Typescript

Language Version

No response

Other information

No response

mrgrain commented 1 year ago

Reference: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#container_definition_memory

homakk commented 1 year ago

My feedback for this ticket after working on it:

Looks like the API does accept memoryReservationMiB for windows containers Customers should set memoryLimitMiB but if you don’t want a memory limit for the container, simply set any value in memoryReservationMiB , and configure the agent to use ECS_ENABLE_MEMORY_UNBOUNDED_WINDOWS_WORKAROUND environment variable.

Which is documented here: https://github.com/aws/amazon-ecs-agent/blob/master/README.md

When true, ECS will ignore the memory reservation parameter (soft limit) to run along with memory bounded tasks in Windows. To run a memory unbounded task, omit the memory hard limit and set any memory reservation, it will be ignored.

So cdk to require either memory limits for windows containers.

For reference you can check following docs: https://github.com/aws/amazon-ecs-agent/blob/master/README.md#environment-variables https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-agent-config.html