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): services essential container exceptions thrown too soon #13240

Merged
merged 5 commits into from
Feb 26, 2021

Conversation

misterjoshua
Copy link
Contributor

@misterjoshua misterjoshua commented Feb 23, 2021

This PR defers the A TaskDefinition must have at least one essential container
error to the validate phase.

Closes #13239


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

@gitpod-io
Copy link

gitpod-io bot commented Feb 23, 2021

@misterjoshua misterjoshua changed the title fix(ecs): at default container exception throws too soon fix(ecs): ec2 and fargate service default container exceptions thrown too soon Feb 23, 2021
@github-actions github-actions bot added the @aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud label Feb 23, 2021
@misterjoshua misterjoshua changed the title fix(ecs): ec2 and fargate service default container exceptions thrown too soon fix(ecs): services default container exceptions thrown too soon Feb 23, 2021
@misterjoshua
Copy link
Contributor Author

P.S., I'm not sure if this is a feature, fix, or chore, so I picked fix because I don't know what I'd write in the README to pass the PR linter for a feat, but it fixes a Dx issue from my perspective.

@misterjoshua misterjoshua changed the title fix(ecs): services default container exceptions thrown too soon fix(ecs): services essential container exceptions thrown too soon Feb 24, 2021
if (!props.taskDefinition.defaultContainer) {
throw new Error('A TaskDefinition must have at least one essential container');
protected onValidate() {
const validationErrors = super.onValidate();
Copy link
Contributor

Choose a reason for hiding this comment

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

I like the change, but we're changing the way we do validations in v2, and we need new code to be compatible with the new way of doing things.

New way looks like:

this.node.addValidation({
   validate: () => !this.taskDefinition.defaultContainer ? ['A taskdefinition...'] : [],
});

@misterjoshua
Copy link
Contributor Author

misterjoshua commented Feb 25, 2021

I looked at the v2-main branch and undid the bit where I tried to bring the addXxxCapacity validation into the same addValidation as this essential container validation so that there's not a v2 merge conflict problem.

@mergify
Copy link
Contributor

mergify bot commented Feb 26, 2021

Thank you for contributing! Your pull request will be updated from master 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: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: b8caf20
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@mergify
Copy link
Contributor

mergify bot commented Feb 26, 2021

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit c174f6c into aws:master Feb 26, 2021
@misterjoshua misterjoshua deleted the validation-deferral branch February 26, 2021 17:58
@SoManyHs SoManyHs added @aws-cdk/aws-ecs Related to Amazon Elastic Container and removed @aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud labels Mar 4, 2021
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(ecs): defer the Fargate/Ec2Service essential container exception to the validation phase
4 participants