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

[Bug]: Not possible to rename stage - Running into a deadlock #2972

Open
1 task
JESCHO99 opened this issue Aug 1, 2024 · 5 comments
Open
1 task

[Bug]: Not possible to rename stage - Running into a deadlock #2972

JESCHO99 opened this issue Aug 1, 2024 · 5 comments
Labels
bug Used to mark issues with provider's incorrect behavior

Comments

@JESCHO99
Copy link

JESCHO99 commented Aug 1, 2024

Terraform CLI Version

1.5.7

Terraform Provider Version

0.92.0

Terraform Configuration

provider "snowflake" {
  role  = "SYSADMIN"
}

terraform {
  required_version = "~> 1.5.0"
  required_providers {
    snowflake = {
      source  = "Snowflake-Labs/snowflake"
      version = "~> 0.92.0"
    }
  }
}

resource "snowflake_database" "this" {
  name = "LOCAL_TEST_DB"
}

resource "snowflake_schema" "this" {
  name     = "TESTING"
  database = snowflake_database.this.name
}

resource "snowflake_table" "table_v1" {
  database                    = snowflake_database.this.name
  schema                      = snowflake_schema.this.name
  name                        = "TEST_V1"
  change_tracking             = false

  column {
    name     = "ID"
    type     = "INTEGER"
  }

  column {
    name = "NAME"
    type = "VARCHAR(255)"
  }
}

resource "snowflake_table" "table_v2" {
  database                    = snowflake_database.this.name
  schema                      = snowflake_schema.this.name
  name                        = "TEST_V2"
  change_tracking             = false

  column {
    name     = "ID"
    type     = "INTEGER"
  }

  column {
    name = "NAME"
    type = "VARCHAR(255)"
  }
}

resource "snowflake_stage" "stage_v1" {
  name        = "TEST_V1"
  database    = snowflake_database.this.name
  schema      = snowflake_schema.this.name
}

resource "snowflake_stage" "stage_v2" {
  name        = "TEST_V2"
  database    = snowflake_database.this.name
  schema      = snowflake_schema.this.name
}

Category

category:resource

Object type(s)

resource:stage

Expected Behavior

When the provided terraform code is applied in Snowflake the Database, Schema, two tables and two named stages can be deployed successful. Everything is working as expected so far. Due to manual changes on Snowflake someone executed a rename command on one of the named stages: alter stage LOCAL_TEST_DB.TESTING.TEST_V1 rename to POST_TEST_V1;

When executing a terraform plan now in Terraform the expected behaviour would be that terraform recognizes that the defined stage no longer exists and will show a create stage in the produced plan. When this plan is executed terraform will create a new stage having the "old" name. In Snowflake there will be the renamed "old" stage and the newly created stage with the "old" name.

Actual Behavior

After a rename of an existing stage the provider runs into an error which does not longer allow for plan, apply or destroy commands.
image
image
It seems that it is missing the behaviour that the provider can differ between a describe and a show objects like function. For example for tables the described process is working completely without errors.

Steps to Reproduce

  1. Terraform Apply with the provided code
  2. Manually Rename one of the stages inside of Snowflake with the rename command
  3. Try to execute terraform plan

How much impact is this issue causing?

Medium

Logs

No response

Additional Information

No response

Would you like to implement a fix?

  • Yeah, I'll take it 😎
@JESCHO99 JESCHO99 added the bug Used to mark issues with provider's incorrect behavior label Aug 1, 2024
@sfc-gh-asawicki
Copy link
Collaborator

Hey @JESCHO99. Thanks for reaching out to us.

We plan to rework stages soon (https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/v1-preparations/ESSENTIAL_GA_OBJECTS.MD). However, this seems to be an easy fix, i.e. we have to handle this error conditionally like e.g. in the schemas (we are doing it for every resource we redesign).

I should be able to squeeze it in in next week's release (if I can prove that this is really the cause as expected).

sfc-gh-asawicki added a commit that referenced this issue Aug 28, 2024
sfc-gh-asawicki added a commit that referenced this issue Aug 28, 2024
@sfc-gh-asawicki
Copy link
Collaborator

Hey @JESCHO99. I have prepared a fix in #3020. It will be released as part of v0.95.0 today or tomorrow (we have to wrap a few other pull requests before making the release).

@JESCHO99
Copy link
Author

Hey @sfc-gh-asawicki, huge thanks for the quick fix!

sfc-gh-asawicki added a commit that referenced this issue Aug 29, 2024
Address two issues: #2972 and #3007:
- Correctly handle renamed/deleted stage
- Handle data type diff suppression better for text and number in the
table resource

References: #2972 #3007
@sfc-gh-asawicki
Copy link
Collaborator

Hey @JESCHO99, we had to postpone the v0.95.0 release to Monday, sorry for the inconvenience.

@sfc-gh-asawicki
Copy link
Collaborator

Hey @JESCHO99 .
We have just released v0.95.0 of the provider. It contains a hotfix for this issue. Please check and let us know if it works for you.

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

2 participants