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

feat: Added Missing Grant Updates + Removed ForceNew #1228

Merged

Conversation

ChrisIsidora
Copy link
Contributor

Added missing update function on resource grants and removed ForceNew from Shares + Roles. This is added to mitigate the current side effects of ForceNew when you add a Share or Role to an existing Grant. Currently existings grants are revoked and then recreated when you add a share or role to a existing grant that has no implementation of the update function and has ForceNew set to true. This causes current queries / users sessions that uses the existing grants to fail because the existing grants where revoked to be recreated a couple of seconds later. This feature makes it possible to only apply the difference.

This has already been done for a couple of resource grants and works properly.

Test Plan

  • acceptance tests
  • unit tests

@ChrisIsidora
Copy link
Contributor Author

ChrisIsidora commented Sep 21, 2022

@sfc-gh-swinkler Can this be reviewed and then released (it's quite blocking for us)?

@ChrisIsidora
Copy link
Contributor Author

Can someone take a look at this? @sfc-gh-jlove @sfc-gh-swinkler?

func UpdateExternalTableGrant(d *schema.ResourceData, meta interface{}) error {
// for now the only thing we can update are roles or shares
// if nothing changed, nothing to update and we're done
if !d.HasChanges("roles", "shares") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

since everything else is marked as forcenew, this code will actually never run. but at least it makes it clear what future work needs to be done

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sfc-gh-swinkler The ForceNew should be removed that's why the Update was implemented

@sfc-gh-swinkler
Copy link
Collaborator

/ok-to-test sha=h555490c

@github-actions
Copy link

Integration tests failure for h555490c

@sfc-gh-swinkler
Copy link
Collaborator

--- FAIL: TestProvider (0.03s)
provider_test.go:22:
Error Trace: /home/runner/work/terraform-provider-snowflake/terraform-provider-snowflake/pkg/provider/provider_test.go:22
Error: Received unexpected error:
1 error occurred:
* resource snowflake_row_access_policy_grant: No Update defined, must set ForceNew on: []string{"roles"}

@ChrisIsidora this looks good, but you missed one of the updates functions to the snowflake_row_access_policy_grant schema.

@ChrisIsidora
Copy link
Contributor Author

@sfc-gh-swinkler I added the missing Update Function for snowflake_row_access_policy_grant. Can you run the tests again?

@sfc-gh-swinkler
Copy link
Collaborator

/ok-to-test sha=7807218

@sfc-gh-swinkler sfc-gh-swinkler merged commit 1e9332d into Snowflake-Labs:main Sep 29, 2022
@sfc-gh-swinkler
Copy link
Collaborator

thank you for your contribution!

@github-actions
Copy link

Integration tests failure for 7807218

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.

2 participants