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

err = missing destination name kind in *[]snowflake.Database #1868

Closed
rjoelnorgren opened this issue Jun 8, 2023 · 36 comments
Closed

err = missing destination name kind in *[]snowflake.Database #1868

rjoelnorgren opened this issue Jun 8, 2023 · 36 comments
Labels
bug Used to mark issues with provider's incorrect behavior

Comments

@rjoelnorgren
Copy link

Provider Version

0.64

Terraform Version

1.4.6

Describe the bug
Snowflake release 7.13 adds the kind column to the show databases command. This behavior change was enabled by default in the 7.19 release:

select current_version();
-- +-------------------+                                                           
-- | CURRENT_VERSION() |
-- |-------------------|
-- | 7.19.2            |
-- +-------------------+

I believe this is now causing the state refresh for our existing databases to fail:

Error: unable to scan row for SHOW DATABASES LIKE 'ANALYTICS' err = missing destination name kind in *[]snowflake.Database

  with snowflake_database.analytics,
  on databases.tf line 1, in resource "snowflake_database" "analytics":
   1: resource "snowflake_database" "analytics" {

Expected behavior

The state of the database refreshes successfully.

Code samples and commands

resource "snowflake_database" "analytics" {
  name                        = "ANALYTICS"
  data_retention_time_in_days = 14
  is_transient                = false
}

Additional context
A patch for this change would be appreciated. In particular, #1845 is a major friction to us upgrading beyond 0.64.

@rjoelnorgren rjoelnorgren added the bug Used to mark issues with provider's incorrect behavior label Jun 8, 2023
@rjoelnorgren
Copy link
Author

Snowflake case #00543276.

@rjoelnorgren
Copy link
Author

As a work around, we have disabled bundle 2023_03 which appears to have resolved the issue for now:

select system$disable_behavior_change_bundle('2023_03');

Assuming this is fixed in a release before the opt out period has ended, we ideally would prefer to not have to remove and re-import most of the role grants in our account from terraform state to upgrade (#1845).

@jackwillisupside
Copy link

Hitting this same issue!

@walarue
Copy link

walarue commented Jun 8, 2023

also hitting this

@mcurtisslalom
Copy link

Hitting the same issue on 0.63

@yanlonghe
Copy link

Hitting the same issue on terraform: 1.4.6 and snowflake 0.64

@willwooten
Copy link

same issue 0.61

@skwon615
Copy link

skwon615 commented Jun 8, 2023

I suspect the issue might be happening as early as v0.53.0 (based on this PR). I know basically nothing about Go, but seems like it's just because the Database struct doesn't have this new kind field:

.

@willwooten
Copy link

As a work around, we have disabled bundle 2023_03 which appears to have resolved the issue for now:

select system$disable_behavior_change_bundle('2023_03');

Assuming this is fixed in a release before the opt out period has ended, we ideally would prefer to not have to remove and re-import most of the role grants in our account from terraform state to upgrade (#1845).

this fix did not work for me.

terraform plan does not recognize dbs exist. tries to create them. then apply fails.

@merlixo
Copy link

merlixo commented Jun 8, 2023

Same issue on 0.65

@astanfel
Copy link
Contributor

astanfel commented Jun 8, 2023

This started effecting us today on 0.64

@akshjain83
Copy link

Same issue for us as well. Are there are any plans for the fix here?

@sfc-gh-swinkler
Copy link
Collaborator

This was fixed in 0.66 as part of the databases SDK refactoring: #1840. Essentially the driver we were using was throwing an error when a field wasn't found in the scanned struct. We have changed that to not throw an error. If this field isn't found, it will just set it to an empty string. Furthermore, we did add "Kind" https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/pkg/sdk/databases.go#L571.

Please let me know after upgrading to 0.66 if this is still an issue and i would be happy to work with you to resolve it.

@willwooten
Copy link

i upgraded to 0.66.1 still not working. Everything was fine yesterday, stopped working today. terraform plan doesn't recognize dbs already exist.

@ryan-keswick
Copy link

Same is on 0.64

@rjoelnorgren
Copy link
Author

This was fixed in 0.66 as part of the databases SDK refactoring: #1840. Essentially the driver we were using was throwing an error when a field wasn't found in the scanned struct. We have changed that to not throw an error. If this field isn't found, it will just set it to an empty string. Furthermore, we did add "Kind" https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/pkg/sdk/databases.go#L571.

Please let me know after upgrading to 0.66 if this is still an issue and i would be happy to work with you to resolve it.

@sfc-gh-swinkler are there any plans to resolve #1845? This issue complicates upgrading from 0.64 to later versions.

@ppo-38
Copy link

ppo-38 commented Jun 9, 2023

Same in 0.64 and can't use 0.66 or higher for the moment because of #1845 which seems to remove all grants realized outside of terraform. So for the moment, we are totally blocked

@merlixo
Copy link

merlixo commented Jun 9, 2023

This was fixed in 0.66 as part of the databases SDK refactoring: #1840. Essentially the driver we were using was throwing an error when a field wasn't found in the scanned struct. We have changed that to not throw an error. If this field isn't found, it will just set it to an empty string. Furthermore, we did add "Kind" https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/pkg/sdk/databases.go#L571.

Please let me know after upgrading to 0.66 if this is still an issue and i would be happy to work with you to resolve it.

Upgrading to 0.66.1 solved the issue for us.

@yuukiyamanaka
Copy link

Same in 0.64 and can't use 0.66 or higher for the moment because of #1845 which seems to remove all grants realized outside of terraform. So for the moment, we are totally blocked

I encounter the same problem.

@funes79
Copy link
Contributor

funes79 commented Jun 9, 2023

Same issue here, 0.66.1 fixes the DBs visibility, but in the same time it wants to recreate ALL grants.

@attekei
Copy link

attekei commented Jun 9, 2023

Same in 0.64 and can't use 0.66 or higher for the moment because of #1845 which seems to remove all grants realized outside of terraform. So for the moment, we are totally blocked

Same same

@willwooten
Copy link

We think that whatever the change was that caused the original issue deleted the dbs from the terraform state file when i ran 0.61.0. So after i updated to 0.66.1 that state file was already damaged / still thinks dbs dont exist when making plan

@Relativity74205
Copy link
Contributor

This was fixed in 0.66 as part of the databases SDK refactoring: #1840. Essentially the driver we were using was throwing an error when a field wasn't found in the scanned struct. We have changed that to not throw an error. If this field isn't found, it will just set it to an empty string. Furthermore, we did add "Kind" https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/pkg/sdk/databases.go#L571.

Please let me know after upgrading to 0.66 if this is still an issue and i would be happy to work with you to resolve it.

@sfc-gh-swinkler We also cannot upgrade to 0.66 as #1845 breaks our setup. Among other things, all the grants performed by AzureAD are dropped.

@walarue
Copy link

walarue commented Jun 9, 2023

#1845 does make this really rough! We upgraded to 0.66, which does fix the error, but we are unable to manage any snowflake grants in terraform, because if we do any grants outside of terraform are revoked. Currently I'm working around this by using lifecycle blocks to ignore the users and roles lists in grant resources, but this definitely isn't workable outside of just unblocking my pipelines

@ppo-38
Copy link

ppo-38 commented Jun 10, 2023

Snowflake seems to have enabled bundle 2023_03 this week which is now in "opt-out period".

In this bundle, there is a change on the SHOW DATABASES command which has a new colmun named KIND (more info on snowflake documentation). I suppose that this change is at the origin of our problems.

For my part, I have disabled this bundle and trouble was solved for us.
Command to disable the bundle : select SYSTEM$DISABLE_BEHAVIOR_CHANGE_BUNDLE('2023_03');

Nevertheless, bundle will be enable by default in 2 months (without possibility to disable it) so I think that we will have to upgrade to a new release of the provider and for my part, I hope that issue #1845 will be solved...

@mlorek
Copy link
Contributor

mlorek commented Jun 12, 2023

#1872 should fix it

@mlorek mlorek mentioned this issue Jun 12, 2023
2 tasks
@natashamathur
Copy link

@walarue were you able to find a workaround for this? I'm hesitant to upgrade to 0.66.1 because our Terraform user itself was granted permission outside of terraform

@willwooten
Copy link

after i updated to 0.66 and cleaned the state file it worked but causes other problems with some of the grants

@toni-moreno
Copy link

Same to us. Without any change in the terraform config or in the snowflake platform ( current snowflake version 7.20.0)

0.61 provider version

with 0.61 current provider version, db's are not recognized anymore . And it tries to create them:

   # snowflake_database.db["MY_DB"] will be created
  + resource "snowflake_database" "db" {
      + data_retention_time_in_days = 30
      + id                          = (known after apply)
      + is_transient                = false
      + name                        = "MY_DB"
    }

  # Plan: 18 to add, 0 to change, 0 to destroy. <--------- !!!!

0.65 provider version

with 0.65 provider version this error happens.

│ Error: unable to scan row for SHOW DATABASES LIKE 'MY_DB' err = missing destination name kind in *[]snowflake.Database
│ 
│   with snowflake_database.db["MY_DB"],
│   on db_creation.tf line 38, in resource "snowflake_database" "db":
│   38: resource "snowflake_database" "db" {
│ 

> 0.66 provider version

with 0.66.1 and 0.66.2 db problem seems to be fixed but now it want to change role_grants config .

It is adding a new parameter enable_multiple_grants = true and also trying to remove some of the users belonging to the role. This is a very big trouble.

  # snowflake_role_grants.role_grant["MY_ROL"] will be updated in-place
  ~ resource "snowflake_role_grants" "role_grant" {
      + enable_multiple_grants = true
        id                     = "MY_ROL||XXXXXXX,YYYYYYYY,ZZZZZZZ"
      ~ users                  = [
          - "XXXXXXX",
          - "YYYYYYY",
          - "ZZZZZZZ"
        ]
        # (2 unchanged attributes hidden)
    }


Any idea on how to continue working with terraform and snowflake??, I can not do new changes  because it will destroy valid snowflake configurations.

@funes79
Copy link
Contributor

funes79 commented Jun 15, 2023

@toni-moreno very well summarized, we are in the same situation. I was expecting some migration guide for such a big change for grants rewamp.

@toni-moreno
Copy link

In my current configuration we don't use terraform to provision real users ( we have an Azure AD integration to automatically provision real users from the Azure AD ).

In this context, as a workaround to avoid removing users in the next terraform apply I've changed my snowflake_role_grants resource definition adding enable_multiple_grants = false and a ignore_changes for users in a lifecycle block

resource "snowflake_role_grants" "role_grant" {

  enable_multiple_grants = false
  role_name              = XXXX
  roles                  =  [ YYYY ]
  lifecycle {
    ignore_changes = [users]
  }

}

I hope this can help to other administrators in a similar context. ( maybe won't be a good workaround if this terraform config is used also to provision generic services users for external tooling connection, something I will need in the future)

@mcurtisslalom
Copy link

mcurtisslalom commented Jun 15, 2023

I second @toni-moreno comment above. Updating to version 0.66.2 along with ensuring the enable_multiple_grants flag is declared in all grants worked for me. Note that I had some set to false and some set to true depending on the resource and it honored it either way.

@skwon615
Copy link

Hi @sfc-gh-swinkler - thanks for approving #1872. A common pain-point from this thread is that several teams (myself included) can't upgrade to version 0.65+ because of #1845. So if that issue won't be resolved soon, is it possible to release something like a v0.64.1 that just adds the change from #1872 into 0.64.0, so that teams can use their current provider versions in the meantime?

@susanneauxmoney
Copy link

In case anyone is interested, we managed to get around any grant revokes by doing this:

  1. disable behaviour change bundle 2023_03
  2. include explicit enable_multiple_grants = true (or false) with provider 0.64.0
  3. upgrade to provider 0.66.2 (-> no changes were stated in terraform plan)
  4. enable behaviour change bundle 2023_03

just to be sure we additionally included the ingnore_changes = [users] as was mentioned here

@erpel
Copy link

erpel commented Jun 20, 2023

Thanks for confirming this works @susanneauxmoney , this opens up a path forward for us too.

@65520
Copy link

65520 commented Oct 6, 2023

We are facing the same issue in 0.63. Also, we cannot upgrade the version. Is there any workaround?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Used to mark issues with provider's incorrect behavior
Projects
None yet
Development

No branches or pull requests