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

Prevent FAILED peerings/attachments from failing deletes #394

Merged
merged 4 commits into from
Sep 21, 2022

Conversation

jjti
Copy link
Contributor

@jjti jjti commented Sep 14, 2022

🛠️ Description

See: #393

I also bumped the AWS provider because anything < v4.0.0 fails out on ARM chips

🚢 Release Note

Release note for CHANGELOG:

* data_source_aws_transit_gateway_attachment
* data_source_aws_network_peering
* data_source_azure_peering_connection

🏗️ Acceptance tests

  • Are there any feature flags that are required to use this functionality?
  • Have you added an acceptance test for the functionality being added?
  • Have you run the acceptance tests on this branch?

Output from acceptance testing:

--- PASS: TestAccAwsPeering (707.25s)
PASS
ok      github.com/hashicorp/terraform-provider-hcp/internal/provider   708.022s

@jjti jjti changed the title Prevent FAILED peerings from failing deletes Prevent FAILED peerings/attachments from failing deletes Sep 14, 2022
@jjti jjti marked this pull request as ready for review September 14, 2022 14:15
@jjti jjti requested a review from a team as a code owner September 14, 2022 14:15
@jjti jjti requested a review from a team September 14, 2022 14:15
@jjti
Copy link
Contributor Author

jjti commented Sep 14, 2022

closes #393

Copy link
Contributor

@chapmanc chapmanc left a comment

Choose a reason for hiding this comment

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

I think I am good with the logic but I am curious how you tested this? Did you create a failed peering on purpose and try to resolve it?

Copy link
Contributor

@bcmdarroch bcmdarroch left a comment

Choose a reason for hiding this comment

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

Thanks for the fix! If possible I'd like to encapsulate these failed state checks inside the peering helpers, rather than repeated over the data source functions.

return nil
}

// If it's in a state where it could later become ACTIVE, wait.
for _, state := range clients.WaitForPeeringToBeActivePendingStates {
waitState := false
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we move this failed/delete check into the WaitFor*State helpers? We can check the state in the result here:

result, err := stateChangeConfig.WaitForStateContext(ctx)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm a bit torn on DRY'ing this into the Waiters because of the shenanigans I'm trying to do here where:

  • if it's a terminal state (FAILED/DELETING) at the start of the Read, throw a Warning
  • if it's a terminal state after trying to wait in the Read, throw an Error

Also this is a specific (hack?) for the Peering data resources that I wouldn't want to add to WaitForPeeringToBeAccepted for example because we always want it to throw an Error there:

peering, err = clients.WaitForPeeringToBeAccepted(ctx, client, peering.ID, hvn1Link.ID, loc, d.Timeout(schema.TimeoutCreate))

I'm not opposed necessarily, but because of two reasons above I left it within the data_resource_* Reads

Copy link
Contributor

@bcmdarroch bcmdarroch Sep 19, 2022

Choose a reason for hiding this comment

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

Hmm I see, that does make sense. In the interest of getting this in, we can leave it like this for now, and revisit whenever we add another peering resource. Maybe leave a comment with that context?

@bcmdarroch bcmdarroch merged commit 6be7a91 into main Sep 21, 2022
@bcmdarroch bcmdarroch deleted the jjtimmons/fix-peering-data-resources branch September 21, 2022 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants