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

fix: refactor ReadWarehouse function to correctly read object parameters #745

Merged
merged 13 commits into from
Nov 29, 2021

Conversation

sonmezonur
Copy link
Contributor

@sonmezonur sonmezonur commented Nov 2, 2021

Fixes #739

#598 has introduced 3 additional parameters (statement_timeout_in_seconds, statement_queued_timeout_in_seconds and max_concurrency_level) for warehouse resource. After adding this feature, terraform plan has started to consistently generate diff for these parameters even when they are already applied. Currently, provider is using SHOW WAREHOUSES LIKE $warehouse_name query but according to doc, these columns are not included in the query output. That is why generated diff always reports zero-value for these fields.

After this update, ReadWarehouse function will run the additional query (SHOW PARAMETERS IN WAREHOUSE $warehouse_name) to fetch warehouse parameters. Not sure if this is the best way but I created a new struct (WarehouseBuilder) by embedding/overriding generic Builder (TaskBuilder uses a similar approach). Updating schema.ResourceData by using the output of this query does not generate diff anymore.

@sonmezonur sonmezonur changed the title warehouse: refactor ReadWarehouse function to correctly read object parameters fix: refactor ReadWarehouse function to correctly read object parameters Nov 2, 2021
@sonmezonur sonmezonur marked this pull request as ready for review November 2, 2021 15:40
@alldoami
Copy link
Contributor

alldoami commented Nov 2, 2021

Could you give a bit more description on what you did in this PR?

@sonmezonur
Copy link
Contributor Author

sonmezonur commented Nov 3, 2021

Hello @alldoami . Updated PR description to give more details on this issue. I hope that makes it clearer. We have encountered this bug while trying to upgrade terraform-provider-snowflake to latest version (from 0.22.0). Atlantis always finds diff while executing plans.

@alldoami
Copy link
Contributor

alldoami commented Nov 3, 2021

/ok-to-test sha=8e1ad2b

@github-actions
Copy link

github-actions bot commented Nov 3, 2021

Integration tests failure for 8e1ad2b

@sonmezonur
Copy link
Contributor Author

Hello @alldoami. I would like to fix integration tests but don't know how to test and work on it locally. Requires account and username to run tests. Could you please help with this?

@alldoami
Copy link
Contributor

alldoami commented Nov 8, 2021

You can set these account variables: https://github.com/chanzuckerberg/terraform-provider-snowflake#pull-request-ci
and run make test-acceptance locally.

@sonmezonur
Copy link
Contributor Author

Hello @alldoami . I updated integration tests and run make test-acceptance locally as you suggested. Could you approve workflows to run tests again?

@@ -105,7 +106,7 @@ var warehouseSchema = map[string]*schema.Schema{
"statement_timeout_in_seconds": {
Type: schema.TypeInt,
Optional: true,
Default: 0,
Default: 172800,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Default value for this parameter is 172800 (https://docs.snowflake.com/en/sql-reference/parameters.html#statement-timeout-in-seconds). I think provider defaults should be the same as Snowflake defaults. What do you think?

@sonmezonur
Copy link
Contributor Author

Should fix #601

@alldoami
Copy link
Contributor

/ok-to-test sha=d9e3c20

@github-actions
Copy link

Integration tests success for d9e3c20

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.

Terraform plan always finds diff for warehouse parameters even if changes are already applied
2 participants