-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
provider/aws: Handle missing EFS mount target in aws_efs_mount_target. #8529
provider/aws: Handle missing EFS mount target in aws_efs_mount_target. #8529
Conversation
This commit resolves issue where the EFS mount target would be already deleted (e.g. it was deleted outside of Terraform, etc.). Also, correct how values are begin set in the ReadFunc to avoid nil pointer dereference. Signed-off-by: Krzysztof Wilczynski <[email protected]>
Resolves #8523. |
d.Set("ip_address", *mt.IpAddress) | ||
d.Set("subnet_id", *mt.SubnetId) | ||
d.Set("network_interface_id", *mt.NetworkInterfaceId) | ||
d.Set("file_system_id", mt.FileSystemId) |
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.
Nice changes!
Tests are passing:
|
@stack72 over to you 🚀 |
@@ -114,8 +114,8 @@ func resourceAwsEfsMountTargetCreate(d *schema.ResourceData, meta interface{}) e | |||
return nil, "error", err | |||
} | |||
|
|||
if len(resp.MountTargets) < 1 { | |||
return nil, "error", fmt.Errorf("EFS mount target %q not found", d.Id()) | |||
if resp.MountTargets != nil && len(resp.MountTargets) < 1 { |
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.
Could this be refactored into a helper method? We tend to repeat this process a lot
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.
You mean a lot in here, or a lot all over the place?
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 believe it's used 3 or 4 times in this file right?
Few nit picks inline but this looks pretty good :) |
@stack72 thank you! I will update as per the suggestions :) |
320e026
to
a7e5953
Compare
region := "non-existant-1" | ||
id := "fs-123456ab" | ||
|
||
expected := fmt.Sprintf("%s.%s.efs.%s.amazonaws.com", az, id, region) |
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 that a black-box approach here would be more useful. i.e. The function should not try to cover all possible cases, because that would mean we'd have to reimplement the function again inside a test - which is what you did here.
e.g. typically you'd be testing that
testedSum(1, 1) == 2
testedSum(3, 4) == 7
rather than
mySumInTest(a, b) == testedSum(a, b)
Having static and simpler tests also makes it easier to spot a bug.
a7e5953
to
09c37b0
Compare
Signed-off-by: Krzysztof Wilczynski <[email protected]>
09c37b0
to
4df4bb6
Compare
This commit adds a helper which can be used to check whether the response contains a valid and non-empty list of EFS file system mount targets. Signed-off-by: Krzysztof Wilczynski <[email protected]>
This commit adds a test to verify the condition where the underlying EFS mount target would be deleted and/or disappear resulting in a new resource to be created to replace it. Signed-off-by: Krzysztof Wilczynski <[email protected]>
@stack72 @radeksimko over to you 🚀 I've added the helper methods with uni tests, plus an acceptance test to check for non-empty plan (the disappear case), the tests are passing: (unit)
(acceptance)
|
Hi @kwilczynski This looks good :) Thanks for adding the extra test:
Paul |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
This commit resolves issue where the EFS mount target would be already
deleted (e.g. it was deleted outside of Terraform, etc.). Also, correct
how values are begin set in the ReadFunc to avoid nil pointer dereference.
Signed-off-by: Krzysztof Wilczynski [email protected]