Skip to content

Ignore members with "deleted:" prefix in bigquery IAM member#4388

Merged
c2thorn merged 2 commits intoGoogleCloudPlatform:masterfrom
c2thorn:bq-dataset-iam-fix
Jan 15, 2021
Merged

Ignore members with "deleted:" prefix in bigquery IAM member#4388
c2thorn merged 2 commits intoGoogleCloudPlatform:masterfrom
c2thorn:bq-dataset-iam-fix

Conversation

@c2thorn
Copy link
Copy Markdown
Member

@c2thorn c2thorn commented Jan 12, 2021

Fixes: hashicorp/terraform-provider-google#8132

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 an issue in `bigquery_dataset_iam_member` where deleted members were not handled correctly

@google-cla google-cla bot added the cla: yes label Jan 12, 2021
@modular-magician
Copy link
Copy Markdown
Collaborator

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

Diff report:

Terraform GA: Diff ( 1 file changed, 3 insertions(+))
Terraform Beta: Diff ( 1 file changed, 3 insertions(+))

@modular-magician
Copy link
Copy Markdown
Collaborator

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

@c2thorn c2thorn requested a review from slevenick January 12, 2021 16:06
// these types are used as keys in the access JSON payload
func iamMemberToAccess(member string) (string, string, error) {
// Remove any occurrence of "deleted:"
member = strings.TrimPrefix(member, "deleted:")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think this is what we want here. This will remove deleted: which will make Terraform believe that the non-deleted member has access when they shouldn't, and cause subsequent updates to try to add back permission to a member that may no longer exist

Can we check for deleted: and then change the switch to read from the correct spot, then return the original member so we don't modify members in here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Tried to modify the switch block and send the full member string as the email (deleted:type:email) but got an error from the API.
Instead, I modified the logic to just skip any members with deleted: prefix

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

do you receive Error: Provider produced inconsistent result after apply?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@edwardmedia for what configuration?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

good with me now

@modular-magician
Copy link
Copy Markdown
Collaborator

I have triggered VCR tests in RECORDING mode for the following tests that failed during VCR: TestAccInstanceTemplateDatasource_filter|TestAccInstanceTemplateDatasource_filter_mostRecent|TestAccDataSourceGoogleSubnetwork|TestAccDataSourceStorageBucketObjectContent_Basic|TestAccActiveDirectoryDomainTrust_activeDirectoryDomainTrustBasicExample|TestAccApigeeOrganization_apigeeOrganizationCloudBasicTestExample|TestAccApigeeOrganization_apigeeOrganizationCloudFullTestExample|TestAccContainerCluster_withConfidentialNodes|TestAccContainerCluster_withPrivateClusterConfigMissingCidrBlock You can view the result here: "https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=166661"

@c2thorn c2thorn changed the title Trim "deleted:" prefix from bigquery IAM member parsing Ignore members with "deleted:" prefix in bigquery IAM member Jan 12, 2021
@c2thorn
Copy link
Copy Markdown
Member Author

c2thorn commented Jan 12, 2021

Tested with the steps provided in hashicorp/terraform-provider-google#7896 (comment)

@c2thorn c2thorn requested a review from slevenick January 12, 2021 19:51
@modular-magician
Copy link
Copy Markdown
Collaborator

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

Diff report:

Terraform GA: Diff ( 1 file changed, 8 insertions(+))
Terraform Beta: Diff ( 1 file changed, 8 insertions(+))

@modular-magician
Copy link
Copy Markdown
Collaborator

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

@modular-magician
Copy link
Copy Markdown
Collaborator

I have triggered VCR tests in RECORDING mode for the following tests that failed during VCR: TestAccInstanceTemplateDatasource_filter|TestAccInstanceTemplateDatasource_filter_mostRecent|TestAccDataSourceGoogleSubnetwork|TestAccDataSourceStorageBucketObjectContent_Basic|TestAccActiveDirectoryDomainTrust_activeDirectoryDomainTrustBasicExample|TestAccApigeeOrganization_apigeeOrganizationCloudBasicTestExample|TestAccApigeeOrganization_apigeeOrganizationCloudFullTestExample|TestAccContainerCluster_withPrivateClusterConfigMissingCidrBlock You can view the result here: "https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=166690"

@c2thorn
Copy link
Copy Markdown
Member Author

c2thorn commented Jan 15, 2021

@slevenick when you get a chance, I added logic to look for the deleted: prefix and skip adding the member to the payload

Copy link
Copy Markdown
Contributor

@slevenick slevenick left a comment

Choose a reason for hiding this comment

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

LGTM

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.

google_bigquery_dataset_iam_member doesn't handle deleted members

4 participants