-
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(codedeploy): CodeDeploy deployment construct for ECS #22455
Conversation
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.
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.
fa58bc5
to
7269071
Compare
This PR is showing a failure in |
Currently, the `prlint` tool lists the files on a PR to enforce new integration tests are created for `feat` changes. The tool is not using pagination for list files and is using the default of `30` files per page. This means a PR could be incorrectly flagged for missing integration tests if the test files occur after the first 30 files in the PR. Example of this can be seen in #22455 This PR enables pagination on the `listFiles` call to ensure the validation rules are looking at all files in the PR, not just the first 30. ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Hi, the referenced PR has been merged, I'd say fix the conflicts, try again! And, as always, thank you for contributing! |
✅ Updated pull request passes all PRLinter validations. Dissmissing previous PRLinter review.
e2bc0d7
to
894f36d
Compare
@Naumel - thanks, ready for review! |
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.
@cplee thanks for the PR! This round I've only focused on the deployment provider.
@@ -0,0 +1,116 @@ | |||
import { Logger } from '@aws-lambda-powertools/logger'; | |||
import { CodeDeploy } from '@aws-sdk/client-codedeploy'; |
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.
For now lets not introduce any new dependencies. I think we should be able to just use the libraries that come built in with the lambda runtime.
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.
Sure. It'll take a bit of time to rewrite all the tests to use the older style of mocks though.
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.
These changes have been completed and are ready to review.
}); | ||
// cancel deployment and rollback | ||
try { | ||
const resp = await codedeployClient.stopDeployment({ |
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.
Should we first look to see if the deployment with the given deploymentId
is in process? If it isn't then there is nothing to do.
If there is an in progress deployment that we stop, I think we should then track the progress of that.
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.
Should we first look to see if the deployment with the given deploymentId is in process? If it isn't then there is nothing to do.
This can be unreliable in the event of race conditions. Better to try to stop and handle situations where there isn't a deployment in progress as a success and final event.
If there is an in progress deployment that we stop, I think we should then track the progress of that.
This is already properly handled in the is-complete.ts
handler.
}); | ||
switch (event.RequestType) { | ||
case 'Create': | ||
case 'Update': { |
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.
What happens if we create a deployment while there is one in progress? I don't think we should just create a new one on top.
Should we look for an existing deployment and if there is one:
- throw an error to fail the stack operation?
- start tracking that one instead of creating a new one?
- something else?
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.
The CodeDeploy service will throw an error if a deployment is already in progress. I'd rather rely on the service to own enforcing this.
RequestType: string; | ||
|
||
/** | ||
* The physical resource id. Could be undefined for 'Create' events. |
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.
IsComplete
should be called with the results of the on-event
right? So the physicalResourceId should never be undefined.
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.
Good call. I will update the comments to clarify.
*/ | ||
export interface IsCompleteResponse { | ||
/** | ||
* True iff the deployment is in a final state. |
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.
* True iff the deployment is in a final state. | |
* True if the deployment is in a final state. |
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.
This was intended to say iff
...will replace with longer version of if and only if
} catch (e) { | ||
logger.error('Unable to determine deployment status', e as Error); | ||
if (event.RequestType === 'Delete') { | ||
logger.warn('Ignoring error - nothing to do', { complete: true }); |
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.
I think we do want to fail under certain scenarios. If there is still a deployment in process there is some error deleting it, but we make this resource as successfully deleted we might run into errors trying to delete downstream resources (can you delete a deployment group while a deployment is in process?)
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.
I think this is asking for trouble. Raising errors from custom resources during delete events is the quickest way to get a stack into a state in which it can't be updated or rolled back cleanly and the only resort is to terminate and start over.
logger.warn('Ignoring error', e as Error); | ||
} | ||
|
||
return {}; |
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.
I think we need to return some data here in order for it to be processed by the IsComplete
handler.
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.
Works fine without it, but I'll add it anyway.
* The properties of the CodeDeploy Deployment to create | ||
*/ | ||
interface DeploymentProperties { | ||
description: string; |
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.
Can you add docstrings for all the properties in this file.
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.
Done
Pull request has been modified.
@corymhall - I've addressed a few of the comments and also replied to a couple that could use more discussion. I've completed the redo of the unit tests. I'd be interested in hearing your feedback on some of the comments I made. Thanks! |
Currently, the `prlint` tool lists the files on a PR to enforce new integration tests are created for `feat` changes. The tool is not using pagination for list files and is using the default of `30` files per page. This means a PR could be incorrectly flagged for missing integration tests if the test files occur after the first 30 files in the PR. Example of this can be seen in aws#22455 This PR enables pagination on the `listFiles` call to ensure the validation rules are looking at all files in the PR, not just the first 30. ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
e1b3979
to
32575ad
Compare
@corymhall - this PR has been rebased since #22295 was merged to |
This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state. |
1 similar comment
This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state. |
This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state. |
1 similar comment
This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state. |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state. |
This PR has been in the BUILD FAILING 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. |
This PR has been deemed to be abandoned, and will be automatically closed. Please create a new PR for these changes if you think this decision has been made in error. |
This PR was abandoned in favor of creating a new CDK construct on Construct Hub to provide this functionality: declare const deploymentGroup: codeDeploy.IEcsDeploymentGroup;
declare const taskDefinition: ecs.ITaskDefinition;
new EcsDeployment({
deploymentGroup,
targetService: {
taskDefinition,
containerName: 'mycontainer',
containerPort: 80,
},
}); |
Extends #22295 by adding support for creating Deployments for ECS Deployment Groups.
All Submissions:
Adding new Unconventional Dependencies:
New Features
yarn integ
to deploy the infrastructure and generate the snapshot (i.e.yarn integ
without--dry-run
)?By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license