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

feat(ecs): add support for Fargate PV1.4 ephemeral storage #15440

Merged
merged 2 commits into from
Aug 27, 2021

Conversation

otterley
Copy link
Contributor

@otterley otterley commented Jul 7, 2021

Add support for ephemeral storage on Fargate PV 1.4.0 or later.

Closes #14570


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 Jul 7, 2021

@otterley otterley force-pushed the fargate-ecs-ephemeral-storage branch 2 times, most recently from ea7b87e to bf6d38e Compare July 7, 2021 16:47
@peterwoodworth peterwoodworth added the @aws-cdk/aws-ecs Related to Amazon Elastic Container label Jul 7, 2021
@iwarshak
Copy link

Any ideas when this will get released?

Copy link
Contributor

@upparekh upparekh left a comment

Choose a reason for hiding this comment

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

Thanks so much for adding support for this feature! Just a few nits..

Comment on lines +341 to +347
/**
* The amount (in GiB) of ephemeral storage to be allocated to the task.
*
* Only supported in Fargate platform version 1.4.0 or later.
*/
public readonly ephemeralStorageGiB?: number;

Copy link
Contributor

Choose a reason for hiding this comment

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

Usually an input property would be added as a class attribute if it can possibly be referred to later in the code. I'm curious if there would be such a use case for ephemeral storage for which we need to add it here.

Copy link
Contributor Author

@otterley otterley Aug 17, 2021

Choose a reason for hiding this comment

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

I've run into a number of issues in the past with multiple L2 constructs where their input values were swallowed by the constructor and made inaccessible after that. This poses significant challenges to classes and methods that consume the resulting construct and need to examine it. So I am now making these attributes readable by default, unless there's some really good reason to hide them.

We simply cannot predict the future with certainty as to when these attributes might someday be useful to consumers. It's always easier to make them accessible from the beginning, just in case, rather than hide them by default and then have to undo our mistake later.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hey @otterley, CDK team member weighing in here. In this case, I don't think it is necessary or helpful to make this a public class attribute, since the ephemeralStorageGiB value will be undefined if the user did not provide it in the input props. If the user provided this value to the constructor, then they should be able to design their CDK app in such a way that they have access to that value wherever they need it. In the case where the user does not provide a value here, they may be frustrated that ephemeralStorageGiB is undefined, and not informing them what the default value is.

I am willing to disagree and commit here. Since this is an optional attribute, it is ultimately a 2-way door decision. So, the decision is ultimately up to you.

Comment on lines +116 to +120
/**
* The amount (in GiB) of ephemeral storage to be allocated to the task.
*/
public readonly ephemeralStorageGiB?: number;

Copy link
Contributor

Choose a reason for hiding this comment

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

Same suggestion as before, we can possibly remove adding it as a class attribute here as well.

@@ -115,5 +129,11 @@ export class FargateTaskDefinition extends TaskDefinition implements IFargateTas
compatibility: Compatibility.FARGATE,
networkMode: NetworkMode.AWS_VPC,
});

if (props.ephemeralStorageGiB && (props.ephemeralStorageGiB < 20 || props.ephemeralStorageGiB > 200)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The condition should be:
if (props.ephemeralStorageGiB && (props.ephemeralStorageGiB < 21 || props.ephemeralStorageGiB > 200))
as the current statement would make the ephemeral storage range 20-200 while we want it to be 21-200.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Comment on lines 7 to 9
const taskDefinition = new ecs.FargateTaskDefinition(stack, 'TaskDef', {
ephemeralStorageGiB: 100,
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for being so thorough with the tests! I think the edge cases are covered in the unit tests and perhaps we don't need an integ test for this feature.

Comment on lines 207 to 209
*
* @default - 20GiB
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can be more clear about the default value here given that we are not setting it unless provided by the user. Something like 'None, the task will receive 20 GiB of ephemeral storage by default.'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

@otterley otterley force-pushed the fargate-ecs-ephemeral-storage branch from bf6d38e to b337298 Compare August 17, 2021 18:24
@otterley otterley force-pushed the fargate-ecs-ephemeral-storage branch from b337298 to 63dd00c Compare August 20, 2021 22:15
Copy link
Contributor

@upparekh upparekh left a comment

Choose a reason for hiding this comment

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

LGTM!

@mergify
Copy link
Contributor

mergify bot commented Aug 27, 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: 0c6ba5f
  • 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 f1bf935 into aws:master Aug 27, 2021
@mergify
Copy link
Contributor

mergify bot commented Aug 27, 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).

TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request Sep 6, 2021
Add support for ephemeral storage on Fargate PV 1.4.0 or later.

Closes aws#14570

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
david-doyle-as24 pushed a commit to david-doyle-as24/aws-cdk that referenced this pull request Sep 7, 2021
Add support for ephemeral storage on Fargate PV 1.4.0 or later.

Closes aws#14570

----

*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
@aws-cdk/aws-ecs Related to Amazon Elastic Container
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(aws-ecs): ecs.taskDefinition: Add support for ephemeralStorage
8 participants