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

Retry for deleting default DHCP options, plus pagination plus a test sweeper #8907

Merged
merged 2 commits into from
Jun 13, 2019

Conversation

ryndaniels
Copy link
Contributor

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" comments, they generate extra noise for pull request followers and do not help prioritize the request

References #7873

Release note for CHANGELOG:

BUG FIXES:
* resource/default_vpc_dhcp_options: Add pagination to get the default DHCP options correctly
* resource/vpc_dhcp_options: Add final retry to deleting DHCP options

Output from acceptance testing:

$ make testacc TESTARGS="-run=TestAccAWSDefaultVpcDhcpOptions"
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./... -v -parallel 20 -run=TestAccAWSDefaultVpcDhcpOptions -timeout 120m
?       github.com/terraform-providers/terraform-provider-aws   [no test files]
=== RUN   TestAccAWSDefaultVpcDhcpOptions_basic
=== PAUSE TestAccAWSDefaultVpcDhcpOptions_basic
=== CONT  TestAccAWSDefaultVpcDhcpOptions_basic
--- PASS: TestAccAWSDefaultVpcDhcpOptions_basic (20.89s)
PASS
ok      github.com/terraform-providers/terraform-provider-aws/aws       22.668s


$ make testacc TESTARGS="-run=TestAccAWSDHCPOptions" ==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./... -v -parallel 20 -run=TestAccAWSDHCPOptions -timeout 120m
?       github.com/terraform-providers/terraform-provider-aws   [no test files]
=== RUN   TestAccAWSDHCPOptionsAssociation_basic
=== PAUSE TestAccAWSDHCPOptionsAssociation_basic
=== RUN   TestAccAWSDHCPOptions_importBasic
=== PAUSE TestAccAWSDHCPOptions_importBasic
=== RUN   TestAccAWSDHCPOptions_basic
=== PAUSE TestAccAWSDHCPOptions_basic
=== RUN   TestAccAWSDHCPOptions_deleteOptions
=== PAUSE TestAccAWSDHCPOptions_deleteOptions
=== CONT  TestAccAWSDHCPOptionsAssociation_basic
=== CONT  TestAccAWSDHCPOptions_deleteOptions
=== CONT  TestAccAWSDHCPOptions_importBasic
=== CONT  TestAccAWSDHCPOptions_basic
--- PASS: TestAccAWSDHCPOptions_deleteOptions (19.86s)
--- PASS: TestAccAWSDHCPOptions_basic (23.54s)
--- PASS: TestAccAWSDHCPOptions_importBasic (25.10s)
--- PASS: TestAccAWSDHCPOptionsAssociation_basic (49.07s)
PASS
ok      github.com/terraform-providers/terraform-provider-aws/aws       49.880s

@ghost ghost added size/M Managed by automation to categorize the size of a PR. service/ec2 Issues and PRs that pertain to the ec2 service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Jun 7, 2019
@ryndaniels ryndaniels added bug Addresses a defect in current functionality. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. and removed tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Jun 7, 2019
@ryndaniels ryndaniels requested a review from bflad June 7, 2019 15:25
Copy link
Contributor

@nywilken nywilken left a comment

Choose a reason for hiding this comment

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

Nicely done!I left a few nits to help consolidate things a bit in the test sweeper, but otherwise good to go.

var domainName string
var defaultDomainNameFound, defaultDomainNameServersFound bool

if region == "us-east-1" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit lets start with domainName = region + ".compute.internal" then use the if to change the value is the condition region == "us-east-1" is true.

## remove 'var domainName string' on line #33 
domainName := region + ".compute.internal"
if region == "us-east-1" {
  domainName = "ec2.internal"
}

domainName = region + ".compute.internal"
}

for _, dhcpConfiguration := range dhcpOption.DhcpConfigurations {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be helpful to add a comment that here indicating that we are skipping the default DHCP options here.


for _, dhcpConfiguration := range dhcpOption.DhcpConfigurations {
if aws.StringValue(dhcpConfiguration.Key) == "domain-name" {
if len(dhcpConfiguration.Values) == 0 || len(dhcpConfiguration.Values) > 1 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit to help grok the conditional

Suggested change
if len(dhcpConfiguration.Values) == 0 || len(dhcpConfiguration.Values) > 1 {
if len(dhcpConfiguration.Values) != 1 || dhcpConfiguration.Values[0] == nil {

continue
}

if dhcpConfiguration.Values[0] != nil && aws.StringValue(dhcpConfiguration.Values[0].Value) == domainName {
Copy link
Contributor

Choose a reason for hiding this comment

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

After applying the above you can change this to the following

Suggested change
if dhcpConfiguration.Values[0] != nil && aws.StringValue(dhcpConfiguration.Values[0].Value) == domainName {
if aws.StringValue(dhcpConfiguration.Values[0].Value) == domainName {

defaultDomainNameFound = true
}
} else if aws.StringValue(dhcpConfiguration.Key) == "domain-name-servers" {
if len(dhcpConfiguration.Values) == 0 || len(dhcpConfiguration.Values) > 1 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same changes from above can be applied here.

continue
}

if dhcpConfiguration.Values[0] != nil && aws.StringValue(dhcpConfiguration.Values[0].Value) == "AmazonProvidedDNS" {
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto ☝️

@nywilken nywilken self-assigned this Jun 7, 2019
@ryndaniels ryndaniels merged commit a7b3917 into master Jun 13, 2019
@ryndaniels ryndaniels added this to the v2.15.0 milestone Jun 13, 2019
@ryndaniels ryndaniels deleted the rfd-dhcp-options branch June 20, 2019 11:54
@ghost
Copy link

ghost commented Nov 3, 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 3, 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/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
Development

Successfully merging this pull request may close these issues.

2 participants