Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws_ecs: Previously turned on managed scaling cannot be disabled #29088

Open
JZechy opened this issue Feb 13, 2024 · 2 comments
Open

aws_ecs: Previously turned on managed scaling cannot be disabled #29088

JZechy opened this issue Feb 13, 2024 · 2 comments
Labels
@aws-cdk/aws-ecs Related to Amazon Elastic Container bug This issue is a bug. effort/medium Medium work item – several days of effort p2

Comments

@JZechy
Copy link

JZechy commented Feb 13, 2024

Describe the bug

If you create a ECS cluster with AsgCapacityProvider with managed scaling enabled, you are not able to disable it any time later.

Once the EneableManagedScaling is set to false, the outputted CloudFormation template does not contain the definition for ManagedScaling property anymore, but this is not causing the CloudFormation to turn off the managed scaling.

Expected Behavior

Setting AsgCapacityProvider.EnableManagedScaling to false should turned off the managing scaling.

Current Behavior

When AsgCapacityProvider.EnableManagedScaling is set to false for the capacity provider, CloudFormation template does not contain ManagedScaling property for AWS::ECS::CapacityProvider anymore. But this missing property doesn't cause the managed scaling to be turned off.

Reproduction Steps

  1. Create a ECS cluster with auto-scale group definition:
Cluster cluster = new(this, "cluster", new ClusterProps
{
    ClusterName = _props.StackName,
    Vpc = vpc,
    ContainerInsights = true
});

cluster.AddAsgCapacityProvider(new AsgCapacityProvider(this, "asg-provider", new AsgCapacityProviderProps
{
    AutoScalingGroup = new AutoScalingGroup(this, "auto-scaling", new AutoScalingGroupProps
    {
        AutoScalingGroupName = _props.StackName,
        Vpc = vpc,
        InstanceType = InstanceType.Of(InstanceClass.T3, InstanceSize.NANO),
        MinCapacity = 0,
        MaxCapacity = 5,
        MachineImage = EcsOptimizedImage.AmazonLinux2023(),
        InstanceMonitoring = Monitoring.DETAILED,
        SecurityGroup = ConstructSecurityGroup(vpc),
        Role = CreateInstanceRole()
    }),
    CapacityProviderName = _props.StackName
}), new AddAutoScalingGroupCapacityOptions());
  1. After cluster is deployed, change AsgCapacityProvider property EnableManagedScaling to false.

Possible Solution

The ManagedScaling property should be probably still present but with Status set to DISABLED.

Additional Information/Context

Problem occurs only when updating existing cluster. If you create new cluster with scaling disabled, it is created in correct way.

CDK CLI Version

2.126.0

Framework Version

2.124.0

Node.js Version

20.10.0

OS

Fedora 39

Language

.NET

Language Version

8

Other information

No response

@JZechy JZechy added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Feb 13, 2024
@github-actions github-actions bot added the @aws-cdk/aws-ecs Related to Amazon Elastic Container label Feb 13, 2024
@pahud
Copy link
Contributor

pahud commented Feb 13, 2024

Sounds like it only happens when updating the existing cluster. I am not sure if we should explicitly set it as false when undefined but we appreciate your workaround here.

@pahud pahud added p2 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Feb 13, 2024
@smvgau
Copy link

smvgau commented Jun 11, 2024

Bumping this because this affects me as well. It's a surprising effect because the default examples within CDK describe using the capacity provider and enabling this, but no where does it describe how permanent this effect currently is.

Note this is also a problematic issue because allowing for AWS to manage this, allows for conflicting rules for an ASG to have, causing thrashing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ecs Related to Amazon Elastic Container bug This issue is a bug. effort/medium Medium work item – several days of effort p2
Projects
None yet
Development

No branches or pull requests

3 participants