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(efs): EFS fails to create when using a VPC with multiple subnets per availability zone #12097

Merged
merged 30 commits into from Jan 31, 2021

Conversation

daisuke-yoshimoto
Copy link
Contributor

@daisuke-yoshimoto daisuke-yoshimoto commented Dec 15, 2020

Fixes #10170

Fixes

This PR has been modified so that it does not create a mount target if only VPC is specified in the EFS file system.

Bug

Currently, if a VPC is specified and no subnet is specified, the subnet search criteria are passed as undefined, all subnets in the VPC are retrieved, and mount targets are generated for all subnets in the VPC. I will. Since mount targets can only be created in one subnet for each Availability Zone, the above behavior will result in duplicate Availability Zones between mount targets, resulting in an error when creating the mount target.


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 Dec 15, 2020

@mergify
Copy link
Contributor

mergify bot commented Dec 15, 2020

Title does not follow the guidelines of Conventional Commits. Please adjust title before merge.

@SomayaB SomayaB changed the title Fix #10170 fix(efs): New EFS fails to create Dec 16, 2020
@github-actions github-actions bot added the @aws-cdk/aws-efs Related to Amazon Elastic File System label Dec 16, 2020
@daisuke-yoshimoto
Copy link
Contributor Author

daisuke-yoshimoto commented Dec 16, 2020

This fix breaks the existing test. Existing tests expect a mount target to be created even if you only specify vpc. Is this the expected specification?

test('default file system is created correctly', () => {

If so, if only VPC is specified, is it better to create a mount target for each AZ subnet in vpc instead of not generating a mount target?

@@ -272,11 +272,13 @@ export class FileSystem extends Resource implements IFileSystem {
defaultPort: ec2.Port.tcp(FileSystem.DEFAULT_PORT),
});

this.mountTargetsAvailable = [];
if (props.vpcSubnets === undefined) return;
Copy link
Contributor

Choose a reason for hiding this comment

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

let's add a test for this. should there be a warning or error to indicate that mounts targets are not created

@shivlaks
Copy link
Contributor

@daisuke-yoshimoto thanks for submitting this fix! i'd been trying to reproduce the failure conditions for a little bit now. can you ensure you update the commit details to include the scenario where this case materializes?

It should be captured in the commit details along with the approach taken to resolve it.

@mergify mergify bot dismissed shivlaks’s stale review December 17, 2020 03:58

Pull request has been modified.

Copy link
Contributor

@shivlaks shivlaks left a comment

Choose a reason for hiding this comment

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

moving to request changes as mergify dismissed previous review - but there's still outstanding feedback.

@daisuke-yoshimoto
Copy link
Contributor Author

@shivlaks

Thank you for your review.

So, I will follow the instructions and write the explanation and add the test.

As for the specifications, like the console screen and CloudFormation, if we specify only VPC, the mount target will not be generated, so it's okay, isn't it?

@mergify mergify bot dismissed shivlaks’s stale review December 17, 2020 08:18

Pull request has been modified.

@daisuke-yoshimoto
Copy link
Contributor Author

@shivlaks

Sorry I made you wait. I wrote a description of the PR and fixed the test cases.

@daisuke-yoshimoto
Copy link
Contributor Author

@shivlaks

Can you please review this PR?
I wrote a description of the PR and fixed the test cases.

@iliapolo iliapolo added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Jan 28, 2021
@iliapolo
Copy link
Contributor

@daisuke-yoshimoto You still up for wrapping this one out? Just a simple unit test would do.

DeletionPolicy: 'Retain',
UpdateReplacePolicy: 'Retain',
}, ResourcePart.CompleteDefinition));
expectCDK(stack).to(haveResource('AWS::EFS::MountTarget'));
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't strictly assert that only one mount target is created per az. You should validate that only one such resource exists.

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Jan 29, 2021
@mergify mergify bot dismissed iliapolo’s stale review January 29, 2021 13:17

Pull request has been modified.

}));
expectCDK(stack).to(countResources('AWS::EFS::MountTarget', 2));
expectCDK(stack).to(haveResource('AWS::EFS::MountTarget', {
SubnetId: {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does this ensure that the mount targets are created in different az's?

Seems to me that the subnets you are asserting on might be in the same AZ.

I think your previous approach was good, creating a vpc with a single az and two subnets, you just needs to assert only a single mount target was created even though there are two subnets in the VPC.

@iliapolo iliapolo added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Jan 29, 2021
@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Jan 30, 2021
iliapolo
iliapolo previously approved these changes Jan 31, 2021
@mergify mergify bot dismissed iliapolo’s stale review January 31, 2021 17:54

Pull request has been modified.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: f732eca
  • 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 Jan 31, 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 889d673 into aws:master Jan 31, 2021
@daisuke-yoshimoto daisuke-yoshimoto deleted the fix-10170 branch January 31, 2021 21:04
NovakGu pushed a commit to NovakGu/aws-cdk that referenced this pull request Feb 18, 2021
…per availability zone (aws#12097)

Fixes aws#10170

### Fixes

This PR has been modified so that it does not create a mount target if only VPC is specified in the EFS file system. 

### Bug

Currently, if a VPC is specified and no subnet is specified, the subnet search criteria are passed as undefined, all subnets in the VPC are retrieved, and mount targets are generated for all subnets in the VPC. I will. Since mount targets can only be created in one subnet for each Availability Zone, the above behavior will result in duplicate Availability Zones between mount targets, resulting in an error when creating the mount target.



----

*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-efs Related to Amazon Elastic File System
Projects
None yet
4 participants