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

service/elbv2: Prevent panics with actions deleted outside Terraform #6319

Merged
merged 1 commit into from
Nov 1, 2018

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Nov 1, 2018

We will now always sort the API response by Action.Order for reading into the Terraform state. This could potentially cause a plan difference in configurations which list actions out of order so will need a note in the CHANGELOG, however this behavior seems more desirable than switching to schema.TypeSet and removing the ability to omit order from configurations.

Fixes #6171
Fixes #6256

Changes proposed in this pull request:

  • Remove sortActionsBasedonTypeinTFFile() which did not account for actions performed outside Terraform and instead sort listener.DefaultActions by Order and rule.Actions by Order
  • Add acceptance testing to cover scenario

Previously:

=== CONT  TestAccAWSLBListener_DefaultAction_Order_Recreates
panic: runtime error: index out of range

goroutine 2681 [running]:
github.com/terraform-providers/terraform-provider-aws/aws.sortActionsBasedonTypeinTFFile(0x441e604, 0xe, 0xc00000f5f0, 0x1, 0x1, 0xc00078ddc0, 0x0, 0xc000702ac0, 0x39eee80)
	/Users/bflad/go/src/github.com/terraform-providers/terraform-provider-aws/aws/structure.go:1918 +0x313
github.com/terraform-providers/terraform-provider-aws/aws.resourceAwsLbListenerRead(0xc00078ddc0, 0x3e81980, 0xc0005f6000, 0xc00078ddc0, 0x0)
	/Users/bflad/go/src/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_lb_listener.go:553 +0x3ff
=== CONT  TestAccAWSLBListenerRule_Action_Order_Recreates
panic: runtime error: index out of range

goroutine 2952 [running]:
github.com/terraform-providers/terraform-provider-aws/aws.sortActionsBasedonTypeinTFFile(0x440a5f0, 0x6, 0xc000612aa0, 0x1, 0x1, 0xc000320000, 0x0, 0xc000cb91f0, 0x1015115)
	/Users/bflad/go/src/github.com/terraform-providers/terraform-provider-aws/aws/structure.go:1918 +0x313
github.com/terraform-providers/terraform-provider-aws/aws.resourceAwsLbListenerRuleRead(0xc000320000, 0x3e82320, 0xc00078c000, 0xc000320000, 0x0)
	/Users/bflad/go/src/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_lb_listener_rule.go:560 +0x3a2

Output from acceptance testing:

--- PASS: TestAccAWSLBListenerRule_multipleConditionThrowsError (1.88s)
--- PASS: TestAccAWSLBListener_basic (197.21s)
--- PASS: TestAccAWSLBListener_cognito (215.75s)
--- PASS: TestAccAWSLBListenerRule_redirect (229.92s)
--- PASS: TestAccAWSLBListenerRule_basic (231.29s)
--- PASS: TestAccAWSLBListenerRule_cognito (232.58s)
--- PASS: TestAccAWSLBListenerRule_Action_Order_Recreates (238.55s)
--- PASS: TestAccAWSLBListener_DefaultAction_Order (239.66s)
--- PASS: TestAccAWSLBListener_DefaultAction_Order_Recreates (246.70s)
--- PASS: TestAccAWSLBListenerRule_fixedResponse (250.83s)
--- PASS: TestAccAWSLBListenerRule_oidc (251.18s)
--- PASS: TestAccAWSLBListenerRule_changeListenerRuleArnForcesNew (252.49s)
--- PASS: TestAccAWSLBListener_fixedResponse (266.42s)
--- PASS: TestAccAWSLBListener_oidc (284.99s)
--- PASS: TestAccAWSLBListenerRule_updateRulePriority (303.61s)
--- PASS: TestAccAWSLBListener_redirect (308.81s)
--- PASS: TestAccAWSLBListener_https (335.90s)
--- PASS: TestAccAWSLBListenerRule_Action_Order (346.05s)
--- PASS: TestAccAWSLBListenerRule_priority (416.86s)

We will now always sort the API response by Action.Order for reading into the Terraform state. This could potentially cause a plan difference in configurations which list actions out of order so will need a note in the CHANGELOG, however this behavior seems more desirable than switching to schema.TypeSet and removing the ability to omit order from configurations.

Previously:

```
=== CONT  TestAccAWSLBListener_DefaultAction_Order_Recreates
panic: runtime error: index out of range

goroutine 2681 [running]:
github.com/terraform-providers/terraform-provider-aws/aws.sortActionsBasedonTypeinTFFile(0x441e604, 0xe, 0xc00000f5f0, 0x1, 0x1, 0xc00078ddc0, 0x0, 0xc000702ac0, 0x39eee80)
	/Users/bflad/go/src/github.com/terraform-providers/terraform-provider-aws/aws/structure.go:1918 +0x313
github.com/terraform-providers/terraform-provider-aws/aws.resourceAwsLbListenerRead(0xc00078ddc0, 0x3e81980, 0xc0005f6000, 0xc00078ddc0, 0x0)
	/Users/bflad/go/src/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_lb_listener.go:553 +0x3ff
=== CONT  TestAccAWSLBListenerRule_Action_Order_Recreates
panic: runtime error: index out of range

goroutine 2952 [running]:
github.com/terraform-providers/terraform-provider-aws/aws.sortActionsBasedonTypeinTFFile(0x440a5f0, 0x6, 0xc000612aa0, 0x1, 0x1, 0xc000320000, 0x0, 0xc000cb91f0, 0x1015115)
	/Users/bflad/go/src/github.com/terraform-providers/terraform-provider-aws/aws/structure.go:1918 +0x313
github.com/terraform-providers/terraform-provider-aws/aws.resourceAwsLbListenerRuleRead(0xc000320000, 0x3e82320, 0xc00078c000, 0xc000320000, 0x0)
	/Users/bflad/go/src/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_lb_listener_rule.go:560 +0x3a2
```

Output from acceptance testing:

```
--- PASS: TestAccAWSLBListenerRule_Action_Order_Recreates (252.06s)
--- PASS: TestAccAWSLBListener_DefaultAction_Order_Recreates (224.20s)
```
@bflad bflad added bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. service/elbv2 Issues and PRs that pertain to the elbv2 service. labels Nov 1, 2018
@bflad bflad added this to the v1.43.0 milestone Nov 1, 2018
@bflad bflad requested a review from a team November 1, 2018 14:36
@ghost ghost added size/M Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Nov 1, 2018
Copy link
Member

@mbfrahry mbfrahry left a comment

Choose a reason for hiding this comment

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

LGTM

@bflad bflad merged commit 02bde27 into master Nov 1, 2018
@bflad bflad deleted the b-elbv2-action-sorting branch November 1, 2018 18:56
bflad added a commit that referenced this pull request Nov 1, 2018
@bflad
Copy link
Contributor Author

bflad commented Nov 7, 2018

This has been released in version 1.43.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@ghost
Copy link

ghost commented Apr 2, 2020

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 Apr 2, 2020
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. crash Results from or addresses a Terraform crash or kernel panic. service/elbv2 Issues and PRs that pertain to the elbv2 service. size/M Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
2 participants