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

Fix migration to terraform-plugin-testing causes panic in existing test suite #1167

Merged
merged 3 commits into from Mar 16, 2023

Conversation

bendbennett
Copy link
Contributor

Closes: #1166

…eoutError, StateRefreshFunc, StateChangeConf, RetryFunc, RetryContext, Retry, RetryError, RetryableError and NonRetryableError

Equivalent types and functions are now available in the helper/retry package (#1166)
@bendbennett bendbennett added the bug Something isn't working label Mar 9, 2023
@bendbennett bendbennett added this to the v2.25.1 milestone Mar 9, 2023
@bendbennett bendbennett requested a review from a team as a code owner March 9, 2023 17:08
"context"
"time"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to add the exports from the new id package to this set of aliases as well?

image

Copy link
Member

Choose a reason for hiding this comment

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

+1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

++1

Copy link
Member

@bflad bflad left a comment

Choose a reason for hiding this comment

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

Overall looks good, just some things to consider. 👍

@@ -0,0 +1,6 @@
kind: NOTES
body: '''helper/resource: Deprecated `PrefixedUniqueId()` and `UniqueId()`. Use the
`helper/id` package instead.'''
Copy link
Member

Choose a reason for hiding this comment

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

Awkward as it may be, I think we should include enhancement entries for the new packages and target deprecations on minor versions so folks are less "surprised". I'm not sure if its worth calling out that the existing package code was converted to aliases to the migrated code in case that surfaces weirdness with tooling such as bflad/tfproviderlint or other AST-based tooling.

It may also be good if these deprecation notices call out that these deprecations are to assist in migrating to terraform-plugin-testing.

r := retry.NonRetryableError(err)

return &RetryError{
Err: err,
Copy link
Member

Choose a reason for hiding this comment

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

This should use the return value as the called function may change the error.

Suggested change
Err: err,
Err: r.Err,

@@ -76,9 +76,9 @@ If a CRUD function timeout is exceeded, the SDK will automatically return a `con
The retry helper takes a timeout and a retry function.

- The **timeout** value specifies the maximum time Terraform will invoke the retry function. You can retrieve the timeout from the `*schema.ResourceData` struct by passing the timeout key (`schema.TimeoutCreate`) to the `Timeout` method.
- The **retry function** returns either a `resource.NonRetryableError` for unexpected errors/states or a `resource.RetryableError` for expected errrors/states. If the function returns a `resource.RetryableError`, it will re-run the function.
- The **retry function** returns either a `retry.NonRetryableError` for unexpected errors/states or a `retry.RetryableError` for expected errrors/states. If the function returns a `retry.RetryableError`, it will re-run the function.
Copy link
Member

Choose a reason for hiding this comment

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

This documentation wasn't doing it before, but it might be a good time to call out the import for this package since its different than any code example above.

* Expanding aliases to include helper/id

* Expanding contents of changie notes and adding enhancement entries

* Updating documentation to refer to import of helper/retry
@bflad bflad modified the milestones: v2.25.1, v2.26.0 Mar 15, 2023
Copy link
Member

@austinvalle austinvalle left a comment

Choose a reason for hiding this comment

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

🚀

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migration to terraform-plugin-testing causes panic in existing test suite
3 participants