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

fix(ecs): DeploymentAlarms property is specified for ECS service with CODE_DEPLOY and EXTERNAL deployment controller #26317

Merged
merged 4 commits into from
Jul 12, 2023

Conversation

tam0ri
Copy link
Contributor

@tam0ri tam0ri commented Jul 11, 2023

From #25840, ECS L2 construct sets the default configuration for the CfnService.deploymentConfiguration.alarms property to:

alarmNames: [],
rollback: false,
enable: false,

However, alarm based rollback feature is only supported for ECS services that use the rolling update (ECS) deployment controller.
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/deployment-alarm-failure.html

Due to this limitation, when deploymentController is set to CODE_DEPLOY or EXTERNAL, creation for the service will fail by conflict with deploymentConfiguration.alarms property.

This PR solves the issue by skipping to set default configuration for the CfnService.deploymentConfiguration.alarms property for CODE_DEPLOY and EXTERNAL deployment controller.

Closes #26307


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

… CODE_DEPLOY and EXTERNAL deployment controller
@gitpod-io
Copy link

gitpod-io bot commented Jul 11, 2023

@aws-cdk-automation aws-cdk-automation requested a review from a team July 11, 2023 10:49
@github-actions github-actions bot added bug This issue is a bug. p1 repeat-contributor [Pilot] contributed between 3-5 PRs to the CDK labels Jul 11, 2023
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@tam0ri
Copy link
Contributor Author

tam0ri commented Jul 11, 2023

Exemption Request for this quick fix. If integration tests and snapshot are still needed, please let me know.

@aws-cdk-automation aws-cdk-automation added the pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. label Jul 11, 2023
@tam0ri
Copy link
Contributor Author

tam0ri commented Jul 11, 2023

I checked failed build. I want to take a new snapshot for @aws-cdk-testing/framework-integ/test/aws-codedeploy/test/ecs/integ.deployment-group.ts, but I can't execute integ-runner now. npx lerna run build --scope=@aws-cdk-testing/framework-integ failed with the following error.

$ cdk-build
       
       /workspace/aws-cdk/packages/aws-cdk/lib/commands/migrate.ts
         5:24  error  Unable to resolve path to module '../vendor/noctilucent'  import/no-unresolved
       
       ✖ 1 problem (1 error, 0 warnings)
       
       Error: /workspace/aws-cdk/node_modules/eslint/bin/eslint.js . --ext=.ts --resolve-plugins-relative-to=/workspace/aws-cdk/tools/@aws-cdk/cdk-build-tools/lib exited with error code 1

I usually use devcontainer, so I tried to use Gitpod, but the problem does not solved.

@mrgrain
Copy link
Contributor

mrgrain commented Jul 11, 2023

@tam0ri Is your branch up-to-date? We made a change to how we import noctilucent recently.
Also did you receive any other errors during the build?

Comment on lines 686 to 687
} else if (props.deploymentController?.type !== DeploymentControllerType.CODE_DEPLOY &&
props.deploymentController?.type !== DeploymentControllerType.EXTERNAL && this.deploymentAlarmsAvailableInRegion()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason you are checking for the negative here (not CODE_DEPLOY, not EXTERNAL) and not if the controller is ECS?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no particular reason. I fix this not to use negative condition.

Copy link
Contributor

@mrgrain mrgrain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good. Thank you! Just the one small question. If you add the test I can run the snapshots for you.

Edit: Just realized you only need a new snapshot. I can do that.

@tam0ri
Copy link
Contributor Author

tam0ri commented Jul 11, 2023

I pushed the fix. If you have any comment, please feel free to point it out!

Is your branch up-to-date? We made a change to how we import noctilucent recently.

Yes, I already pulled the latest main branch. I'll dig it further more later, but it really helpful that you add a new snapshot.

@tam0ri
Copy link
Contributor Author

tam0ri commented Jul 11, 2023

I could execute integ-runner on Gitpod, so I added a new snapshot by myself.

The previous snapshot includes the invalid configuration (alarm based rollback + CODE_DEPLOY deployment controller). This led creation failure for CFn stack when I executed integration test.

"FargateServiceAC2B3B85": {
"Type": "AWS::ECS::Service",
"Properties": {
"Cluster": {
"Ref": "EcsCluster97242B84"
},
"DeploymentConfiguration": {
"Alarms": {
"AlarmNames": [],
"Enable": false,
"Rollback": false
},
"MaximumPercent": 200,
"MinimumHealthyPercent": 50
},
"DeploymentController": {
"Type": "CODE_DEPLOY"
},

So, I created the new snapshot by --disable-update-workflow the option.

@mrgrain mrgrain added the pr-linter/exempt-integ-test The PR linter will not require integ test changes label Jul 11, 2023
@aws-cdk-automation aws-cdk-automation dismissed their stale review July 11, 2023 19:07

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@tam0ri tam0ri requested a review from mrgrain July 12, 2023 00:34
@mergify
Copy link
Contributor

mergify bot commented Jul 12, 2023

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).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 1bcdeb9
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit b799c82 into aws:main Jul 12, 2023
7 checks passed
@mergify
Copy link
Contributor

mergify bot commented Jul 12, 2023

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).

bmoffatt pushed a commit to bmoffatt/aws-cdk that referenced this pull request Jul 29, 2023
… CODE_DEPLOY and EXTERNAL deployment controller (aws#26317)

From aws#25840, ECS L2 construct sets the default configuration for the `CfnService.deploymentConfiguration.alarms` property to:
```
alarmNames: [],
rollback: false,
enable: false,
```

However, alarm based rollback feature is only supported for ECS services that use the rolling update (ECS) deployment controller.
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/deployment-alarm-failure.html

Due to this limitation, when deploymentController is set to CODE_DEPLOY or EXTERNAL, creation for the service will fail by conflict with `deploymentConfiguration.alarms` property.

This PR solves the issue by skipping to set default configuration for the `CfnService.deploymentConfiguration.alarms` property for CODE_DEPLOY and EXTERNAL deployment controller.

Closes aws#26307

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. p1 pr-linter/exempt-integ-test The PR linter will not require integ test changes pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. repeat-contributor [Pilot] contributed between 3-5 PRs to the CDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ECS Fargate Service: service not created because of alarm based rollback
3 participants