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

Update to SDKv2 #3932

Closed
wants to merge 30 commits into from
Closed

Conversation

megan07
Copy link
Contributor

@megan07 megan07 commented Aug 29, 2020

Fixes hashicorp/terraform-provider-google#6976

I'm struggling with one test still, TestAccProjectIamPolicy_emptyMembers, but wanted to get eyes on this to see if someone can see where (if it's in our code) and also because it's a lot of code.

There are still failures for:
TestAccBigtableInstance_allowDestroy
TestAccOrganizationIamCustomRole_undelete
TestAccProjectIamCustomRole_undelete
TestAccStorageBucket_forceDestroyObjectDeleteError
TestAccLoggingFolderExclusion

I created a PR to fix the first 4 that @paddycarver is looking into.
The last one should be fixed with hashicorp/terraform-plugin-sdk#552
All 5 failures were failures in the testing framework only.

Generated code is at https://github.com/hashicorp/terraform-provider-google/tree/sdkv2 and https://github.com/hashicorp/terraform-provider-google-beta/tree/sdkv2. I'm thinking we'll likely want to merge them first and then do mm, to make sure we have go.mod and go.sum updated correctly.

If this PR is for Terraform, I acknowledge that I have:

  • Searched through the issue tracker for an open issue that this either resolves or contributes to, commented on it to claim it, and written "fixes {url}" or "part of {url}" in this PR description. If there were no relevant open issues, I opened one and commented that I would like to work on it (not necessary for very small changes).
  • Generated Terraform, and ran make test and make lint to ensure it passes unit and linter tests.
  • Ensured that all new fields I added that can be set by a user appear in at least one example (for generated resources) or third_party test (for handwritten resources or update tests).
  • Ran relevant acceptance tests (If the acceptance tests do not yet pass or you are unable to run them, please let your reviewer know).
  • Read the Release Notes Guide before writing my release note below.

Release Note Template for Downstream PRs (will be copied)


@google-cla google-cla bot added the cla: yes label Aug 29, 2020
@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 873 files changed, 4462 insertions(+), 2735 deletions(-))
Terraform Beta: Diff ( 976 files changed, 4809 insertions(+), 2902 deletions(-))
TF Conversion: Diff ( 44 files changed, 208 insertions(+), 121 deletions(-))

@modular-magician
Copy link
Collaborator

I have triggered VCR tests based on this PR's diffs. See the results here: "https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=143334"

Copy link
Member

@rileykarson rileykarson left a comment

Choose a reason for hiding this comment

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

I tried looking for something about TestAccProjectIamPolicy_emptyMembers but didn't find anything. I'd suggest adding logging around the field here + at HEAD.

The policy, err := unmarshalIamPolicy(d.Get("policy_data").(string)) line particularly, I'd be interested in whether d.Get("policy_data").(string) returns the same value between both. (sorry- laptop is slow today so I was browsing the code locally and not in GH, so no link)

@@ -110,6 +110,9 @@ class Examples < Api::Object
# These properties will likely be custom code.
attr_reader :ignore_read_extra

# Needs the random provider defined in ExternalProviders
attr_reader :needs_random
Copy link
Member

Choose a reason for hiding this comment

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

just curious: is there a downside to requiring it in every test?

@@ -27,7 +27,9 @@ func expand<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d T
} else {
// If no full topic given, we expand it to a full topic on the same project
fullTopic := fmt.Sprintf("projects/%s/topics/%s", project, topic)
d.Set("topic", fullTopic)
if err := d.Set("topic", fullTopic); err != nil {
return nil, fmt.Errorf("Error reading topic: %s", err)
Copy link
Member

Choose a reason for hiding this comment

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

Lots of these d.Set errors are "reading". Is that intentional & I'm missing something, or should it be writing/setting? (I've got no idea how we'd change them en-masse, but wouldn't want to make you to have to make that change manually)

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 spent the whole day Friday searching and replacing these, and about part way through I realized the error message that I copied said reading rather than writing, so I changed it for some of them. I can change these if you need me to, or at least as many as I can without spending too much time on it.

@@ -27,7 +27,9 @@ func expand<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d T
} else {
// If no full topic given, we expand it to a full topic on the same project
fullTopic := fmt.Sprintf("projects/%s/topics/%s", project, topic)
d.Set("topic", fullTopic)
if err := d.Set("topic", fullTopic); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Oh no! The SDK path change meant that the rule excluding d.Set from the errcheck lint broke: https://github.com/hashicorp/terraform-provider-google/blob/master/.golangci.yml#L26

This is an improvement to the code so I'd imagine it's worth keeping now that you've made it- sorry that you had to, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oooooooh, that's what did it! oh no :( I was so confused why it was just showing up now, but now that I see it there it makes sense.

@danawillow
Copy link
Contributor

Mentioned this in the sync meeting but putting here for posterity: I think it's too difficult to review this as it is right now, and needs to be broken up into smaller, independent PRs. For example, the d.Set changes look like they could all happen together, and then the reviewer can review the idea of it and skim through the code without worrying about missing anything.

@megan07
Copy link
Contributor Author

megan07 commented Sep 8, 2020

Closing to split this into a couple different PRs

@megan07 megan07 closed this Sep 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrade to SDKv2
5 participants