-
Notifications
You must be signed in to change notification settings - Fork 4k
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
feat(ecs-patterns): add containerCpu
and containerMemoryLimitMiB
property to ApplicationLoadBalancedFargateService
#30920
feat(ecs-patterns): add containerCpu
and containerMemoryLimitMiB
property to ApplicationLoadBalancedFargateService
#30920
Conversation
packages/aws-cdk-lib/aws-ecs-patterns/lib/fargate/application-load-balanced-fargate-service.ts
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you change the PR title from "feat(application-load-balanced-fargate-service): ..." to "feat(ecs-patterns): add containerCpu
and containerMemoryLimitMiB
property to ApplicationLoadBalancedFargateService
"? Because we should specify the module name, not the construct name.
containerCpu
and containerMemoryLimitMiB
property to a ApplicationLoadBalancedFargateService
containerCpu
and containerMemoryLimitMiB
property to a ApplicationLoadBalancedFargateService
Thank you for the suggestion. I have updated the PR title. Please check the changes at your convenience. |
containerCpu
and containerMemoryLimitMiB
property to a ApplicationLoadBalancedFargateService
containerCpu
and containerMemoryLimitMiB
property to ApplicationLoadBalancedFargateService
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR! I made some comments.
packages/aws-cdk-lib/aws-ecs-patterns/test/fargate/load-balanced-fargate-service.test.ts
Outdated
Show resolved
Hide resolved
packages/aws-cdk-lib/aws-ecs-patterns/lib/fargate/application-load-balanced-fargate-service.ts
Show resolved
Hide resolved
Co-authored-by: Kenta Goto (k.goto) <24818752+go-to-k@users.noreply.github.com>
Thanks for the review! I have fixed it, so please check it out! (A link to the fix commit is provided in reply to the thread.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the containerCpu
and the containerMemoryLimitMiB
are larger than (or equal to) the cpu
and the memoryLimitMiB
, will CloudFormation deploy errors occur?
If so, it is good to add validations for them. (and also good to add corresponding unit tests)
for example:
if (
props.containerCpu &&
!Token.isUnresolved(props.containerCpu) &&
props.cpu &&
!Token.isUnresolved(props.cpu) &&
props.containerCpu > props.cpu // or `props.containerCpu >= props.cpu`
) {
throw new Error('containerCpu must be less than or equal to cpu');
}
// The same applies to memory.
// ...
As with the validateHealthyPercentage
method, it may also be possible to check for values that are not negative. (If CFn fails for negative values.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @ren-yamanashi for defining the alternate approach in detail, I would not modify the current behaviour of the construct by setting the default for props.cpu, I believe in case, value of containerCpu and cpu doesn't align with each other, this would result in a failed deployment (please let me know if that is not the case), given that if intention by adding this validation is to fail fast before the deployment itself, can we add a warning instead of an error in the function so that in case these values change in near future it will not block customer deployments.
This PR has been in the CHANGES REQUESTED state for 3 weeks, and looks abandoned. To keep this PR from being closed, please continue work on it. If not, it will automatically be closed in a week. |
Pull request has been modified.
…-add-cpu-memory-props
@@ -152,4 +174,29 @@ export class ApplicationLoadBalancedFargateService extends ApplicationLoadBalanc | |||
throw new Error(`${name}: Must be a non-negative integer; received ${value}`); | |||
} | |||
} | |||
|
|||
private validateContainerCpu(containerCpu?: number, cpu: number = 256) { // default value for cpu is 256 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ren-yamanashi , discussed with @shikha372 and the suggestion is to validate using this.taskDefinition.cpu
since FargateTaskDefinition sets a default for cpu
. i.e.
this.validateContainerCpu(props.containerCpu, this.taskDefinition.cpu);
It looks like we will need to surface cpu
in the FargateTaskDefinition
class as a public readonly member in order to do this. Let us know if you're still planning to work on this, otherwise we can take over to get it merged (we will make sure to credit you as a co-author :) ). Thanks!
…-add-cpu-memory-props
Pull request has been modified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for contributing!
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
@Mergifyio update |
❌ Mergify doesn't have permission to updateFor security reasons, Mergify can't update this pull request. Try updating locally. |
Pull request has been modified.
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Comments on closed issues and PRs are hard for our team to see. |
Issue #20638
Closes #20638
Reason for this change
ApplicationLoadBalancedFargateService did not allow you to specify the CPU and memory of the container.
Description of changes
containerCpu
property toApplicationLoadBalancedFargateServiceProps
containerMemoryLimitMiB
property toApplicationLoadBalancedFargateServiceProps
Description of how you validated changes
Added both unit and integration tests.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license