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

Made bigquery table schema diffsuppress func handle nested lists gracefully #4832

Merged
merged 6 commits into from
Jun 4, 2021

Conversation

melinath
Copy link
Member

@melinath melinath commented Jun 2, 2021

Resolved hashicorp/terraform-provider-google#9230. The comparison function was assuming that if the current object was a list, it was the top-level schema list and could be sorted by field name. However, this logic ended up also getting applied to nested lists, which don't have a field name to sort by (thus causing a panic.)

Specifically, bigquery table schema can specify policyTags per-column.

I believe the purpose of sorting by field name is to prevent diffs if fields in the schema are reordered. We can preserve this logic by pre-sorting the schema by field name prior to passing it to the comparison function. (Note: due to nested fields, ended up going with a different strategy.)

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)

bigquery: Fixed `google_bigquery_table.schema` handling of policyTags

@google-cla google-cla bot added the cla: yes label Jun 2, 2021
@melinath melinath requested review from a team and rileykarson and removed request for a team June 2, 2021 18:57
@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 ( 2 files changed, 125 insertions(+), 11 deletions(-))
Terraform Beta: Diff ( 2 files changed, 125 insertions(+), 11 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=190199"

return false
}

// Sort the first level of the schema by name so reordering the
Copy link
Member

Choose a reason for hiding this comment

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

A field can have fields nested inside of it [schema], so we still need to sort within the JSON function still, right? With this change reordering nested fields fields won't work as I'm reading it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, I didn't know about nested fields! I'll make this support both.

@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 ( 2 files changed, 172 insertions(+), 23 deletions(-))
Terraform Beta: Diff ( 3 files changed, 174 insertions(+), 24 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=190226"

@melinath melinath requested a review from rileykarson June 2, 2021 22:57
@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 ( 2 files changed, 256 insertions(+), 124 deletions(-))
Terraform Beta: Diff ( 3 files changed, 257 insertions(+), 126 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=190226"

@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 ( 2 files changed, 256 insertions(+), 124 deletions(-))
Terraform Beta: Diff ( 2 files changed, 256 insertions(+), 124 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=190389"

@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 ( 2 files changed, 375 insertions(+), 124 deletions(-))
Terraform Beta: Diff ( 2 files changed, 375 insertions(+), 124 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=190411"

@modular-magician
Copy link
Collaborator

I have triggered VCR tests in RECORDING mode for the following tests that failed during VCR: TestAccTags You can view the result here: "https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=190412"

@modular-magician
Copy link
Collaborator

I have triggered VCR tests in RECORDING mode for the following tests that failed during VCR: TestAccBigtableAppProfile_bigtableAppProfileSingleclusterExample|TestAccBigtableAppProfile_bigtableAppProfileMulticlusterExample You can view the result here: "https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=190427"

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.

Terraform plan crashes: interface conversion: interface {} is string, not map[string]interface {}
3 participants