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

ec2: Prevent "InvalidNetworkInterfaceID.NotFound" errors in deleteLingeringLambdaENIs #6037

Merged
merged 1 commit into from
Oct 2, 2018

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Oct 1, 2018

Reference: #4884

Changes proposed in this pull request:

  • resource/aws_security_group: Prevent InvalidNetworkInterfaceID.NotFound errors when deleting lingering network interfaces
  • resource/aws_subnet: Prevent InvalidNetworkInterfaceID.NotFound errors when deleting lingering network interfaces

Previously:

--- FAIL: TestAccAWSLambdaFunction_VPC_withInvocation (70.96s)
    testing.go:588: Error destroying resource! WARNING: Dangling resources
        may exist. The full state and error is shown below.

        Error: Error applying: 1 error occurred:
        	* aws_subnet.subnet_for_lambda (destroy): 1 error occurred:
        	* aws_subnet.subnet_for_lambda: Failed to delete Lambda ENIs: Error waiting for ENI (eni-00233276ead620ddf) to become detached: InvalidNetworkInterfaceID.NotFound: The networkInterface ID 'eni-00233276ead620ddf' does not exist

Output from acceptance testing:

75 tests passed (all tests)
--- PASS: TestAccAWSLambdaFunction_expectFilenameAndS3Attributes (17.79s)
--- PASS: TestAccAWSLambdaFunction_VPC (25.77s)
--- PASS: TestAccAWSLambdaFunction_importLocalFile_VPC (26.44s)
--- PASS: TestAccAWSLambdaFunction_nilDeadLetterConfig (28.61s)
--- PASS: TestAccAWSLambdaFunction_importS3 (32.00s)
--- PASS: TestAccAWSLambdaFunction_VPCRemoval (36.71s)
--- PASS: TestAccAWSLambdaFunction_importLocalFile (38.60s)
--- PASS: TestAccAWSLambdaFunction_runtimeValidation_noRuntime (1.35s)
--- PASS: TestAccAWSLambdaFunction_EmptyVpcConfig (29.80s)
--- PASS: TestAccAWSLambdaFunction_versioned (48.07s)
--- PASS: TestAccAWSLambdaFunction_DeadLetterConfigUpdated (50.63s)
--- PASS: TestAccAWSLambdaFunction_VPCUpdate (50.60s)
--- PASS: TestAccAWSLambdaFunction_DeadLetterConfig (50.88s)
--- PASS: TestAccAWSLambdaFunction_s3 (33.67s)
--- PASS: TestAccAWSLambdaFunction_concurrency (62.02s)
--- PASS: TestAccAWSLambdaFunction_localUpdate_nameOnly (35.21s)
--- PASS: TestAccAWSLambdaFunction_versionedUpdate (66.42s)
--- PASS: TestAccAWSLambdaFunction_s3Update_unversioned (31.26s)
--- PASS: TestAccAWSLambdaFunction_s3Update_basic (38.46s)
--- PASS: TestAccAWSLambdaFunction_localUpdate (44.91s)
--- PASS: TestAccAWSLambdaFunction_updateRuntime (71.60s)
--- PASS: TestAccAWSSecurityGroup_importBasic (26.36s)
--- PASS: TestAccAWSLambdaFunction_runtimeValidation_nodeJs43 (41.60s)
--- PASS: TestAccAWSLambdaFunction_runtimeValidation_java8 (37.76s)
--- PASS: TestAccAWSLambdaFunction_envVariables (91.04s)
--- PASS: TestAccAWSSecurityGroup_importIpv6 (33.03s)
--- PASS: TestAccAWSLambdaFunction_VPC_withInvocation (94.47s)
--- PASS: TestAccAWSLambdaFunction_encryptedEnvVariables (95.53s)
--- PASS: TestAccAWSSecurityGroup_importIPRangesWithSameRules (27.57s)
--- PASS: TestAccAWSLambdaFunction_runtimeValidation_python36 (44.90s)
--- PASS: TestAccAWSSecurityGroup_namePrefix (10.42s)
--- PASS: TestAccAWSLambdaFunction_basic (103.18s)
--- PASS: TestAccAWSSecurityGroup_importSelf (47.88s)
--- PASS: TestAccAWSLambdaFunction_tracingConfig (114.01s)
--- PASS: TestAccAWSSecurityGroup_importIPRangeAndSecurityGroupWithSameRules (48.93s)
--- PASS: TestAccAWSSecurityGroup_self (24.48s)
--- PASS: TestAccAWSSecurityGroup_importSourceSecurityGroup (54.65s)
--- PASS: TestAccAWSSecurityGroup_vpc (24.69s)
--- PASS: TestAccAWSSecurityGroup_invalidCIDRBlock (0.66s)
--- PASS: TestAccAWSSecurityGroup_drift (7.03s)
--- PASS: TestAccAWSSecurityGroup_DefaultEgress_Classic (9.90s)
--- PASS: TestAccAWSSecurityGroup_basic (54.64s)
--- PASS: TestAccAWSLambdaFunction_concurrencyCycle (129.14s)
--- PASS: TestAccAWSSecurityGroup_vpcProtoNumIngress (39.42s)
--- PASS: TestAccAWSSecurityGroup_vpcNegOneIngress (40.81s)
--- PASS: TestAccAWSSecurityGroup_ingressWithCidrAndSGs_classic (15.16s)
--- PASS: TestAccAWSSecurityGroup_DefaultEgress_VPC (28.34s)
--- PASS: TestAccAWSSecurityGroup_importPrefixList (81.19s)
--- PASS: TestAccAWSSecurityGroup_ruleGathering (80.72s)
--- PASS: TestAccAWSSecurityGroup_ipv6 (68.35s)
--- PASS: TestAccAWSSecurityGroup_ingressWithCidrAndSGs (31.23s)
--- PASS: TestAccAWSSecurityGroup_drift_complex (39.91s)
--- PASS: TestAccAWSSecurityGroup_generatedName (50.03s)
--- PASS: TestAccAWSSecurityGroup_Change (62.37s)
--- PASS: TestAccAWSSecurityGroup_ipv4andipv6Egress (27.56s)
--- PASS: TestAccAWSSecurityGroup_CIDRandGroups (40.36s)
--- PASS: TestAccAWSLambdaFunction_tags (117.25s)
--- PASS: TestAccAWSSecurityGroup_MultiIngress (76.95s)
--- PASS: TestAccAWSSecurityGroup_ingressWithPrefixList (41.12s)
--- PASS: TestAccAWSSecurityGroup_RuleDescription (80.52s)
--- PASS: TestAccAWSSecurityGroup_egressWithPrefixList (55.60s)
--- PASS: TestAccAWSSubnet_importBasic (26.29s)
--- PASS: TestAccAWSSecurityGroup_ruleLimitCidrBlockExceededAppend (40.08s)
--- PASS: TestAccAWSSecurityGroup_tags (73.75s)
--- PASS: TestAccAWSSecurityGroup_ruleLimitExceededAppend (58.75s)
--- PASS: TestAccAWSSubnet_basic (44.18s)
--- PASS: TestAccAWSSubnet_enableIpv6 (40.40s)
--- PASS: TestAccAWSSecurityGroup_rulesDropOnError (47.90s)
--- PASS: TestAccAWSSecurityGroup_failWithDiffMismatch (63.51s)
--- PASS: TestAccAWSSecurityGroup_ruleLimitExceededPrepend (56.05s)
--- PASS: TestAccAWSSecurityGroup_ruleLimitExceededAllNew (61.16s)
--- PASS: TestAccAWSSubnet_ipv6 (53.46s)
--- PASS: TestAccAWSLambdaFunction_runtimeValidation_python27 (250.03s)
--- PASS: TestAccAWSSecurityGroup_forceRevokeRules_false (862.44s)
--- PASS: TestAccAWSSecurityGroup_forceRevokeRules_true (1166.51s)

…geringLambdaENIs

Previously:

```
--- FAIL: TestAccAWSLambdaFunction_VPC_withInvocation (70.96s)
    testing.go:588: Error destroying resource! WARNING: Dangling resources
        may exist. The full state and error is shown below.

        Error: Error applying: 1 error occurred:
        	* aws_subnet.subnet_for_lambda (destroy): 1 error occurred:
        	* aws_subnet.subnet_for_lambda: Failed to delete Lambda ENIs: Error waiting for ENI (eni-00233276ead620ddf) to become detached: InvalidNetworkInterfaceID.NotFound: The networkInterface ID 'eni-00233276ead620ddf' does not exist
```
@bflad bflad added bug Addresses a defect in current functionality. service/ec2 Issues and PRs that pertain to the ec2 service. labels Oct 1, 2018
@bflad bflad requested review from jen20 and a team October 1, 2018 19:09
@ghost ghost added the size/XS Managed by automation to categorize the size of a PR. label Oct 1, 2018
Copy link
Contributor

@jen20 jen20 left a comment

Choose a reason for hiding this comment

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

Good catch, I'm surprised I didn't find this in testing.

@@ -1464,8 +1477,11 @@ func networkInterfaceAttachedRefreshFunc(conn *ec2.EC2, id string) resource.Stat
}
describeResp, err := conn.DescribeNetworkInterfaces(describe_network_interfaces_request)

if isAWSErr(err, "InvalidNetworkInterfaceID.NotFound", "") {
return 42, "false", nil
Copy link
Contributor

Choose a reason for hiding this comment

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

What is 42 here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jen20 something I don't necessarily agree with, but an existing convention that is a workaround for return nil, X, nil causing WaitForState() to treat the refresh as a missing resource and automatically retry without exiting the WaitForState() since Target has a value: https://github.com/hashicorp/terraform/blob/master/helper/resource/state.go#L115-L137

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Heh, the second part was what I assumed but thought I would clarify! Is it worth introducing a constant here to make the intent clearer?

@bflad bflad added this to the v1.39.0 milestone Oct 2, 2018
@bflad bflad merged commit 7108da6 into master Oct 2, 2018
@bflad bflad deleted the t-aws_lambda_function-delete-eni branch October 2, 2018 12:51
bflad added a commit that referenced this pull request Oct 2, 2018
@ghost
Copy link

ghost commented Oct 3, 2018

This has been released in version 1.39.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "aws" {
	version = "~> 1.39.0"
}
# ... other configuration ...

@ghost
Copy link

ghost commented May 28, 2019

Hi, using the 2.12.0 AWS provider version we are still getting the following error:

aws_security_group.health_check_agent_sg: Failed to delete Lambda ENIs: InvalidAttachmentID.NotFound: The interface attachment 'eni-attach-0eb0eb99372a3d930' does not exist

Is it possible that there was a regression regarding this issue?

@umangdhaw
Copy link

Hi @Kompi , I'm seeing the same issue. Looking at the code it seems that InvalidAttachmentID.NotFound is nowhere handled

@ghost
Copy link

ghost commented Nov 2, 2019

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Nov 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/ec2 Issues and PRs that pertain to the ec2 service. size/XS Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants