databricks / terraform-provider-databricks

Databricks Terraform Provider
https://registry.terraform.io/providers/databricks/databricks/latest
Other
456 stars 393 forks source link

databricks_sql_table context deadline exceeded #4230

Open jiropardo opened 1 week ago

jiropardo commented 1 week ago

Configuration

# Copy-paste your Terraform configuration here

resource "databricks_sql_table" "event_table" { provider = databricks.workspace
name = "usageEvents"

catalog_name = "test_catalog" schema_name = "test-schema" table_type = "MANAGED" data_source_format = "DELTA"

column { name = "key" type = "string" } column { name = "value" type = "string" } column { name = "partition" type = "int" } column { name = "offset" type = "bigint" } column { name = "timestamp" type = "timestamp" }

cluster_keys = ["key","timestamp"]

warehouse_id = "XXXXXXXXXXXXXX"

}

Expected Behavior

The resource databricks_sql_table spins up a SQL warehouse to run a SQL query to create the table if SQL warehouse is not running. We expect the table creation to succeed all times

Actual Behavior

Trying to create a table using a non running Classic or PRO SQL Warehouse will fail with below error as it waits for the SQL Warehouse to spin up

2024-11-13T23:53:41.261-0600 [ERROR] vertex "databricks_sql_table.event_table" error: cannot create sql table: Post "https://xxxxxxxxxxx.cloud.databricks.com/api/2.0/sql/statements/": context deadline exceeded

Steps to Reproduce

Create a databricks_sql_table referencing a not running PRO / Classic warehouse

Terraform and provider versions

Databricks provider v1.58.0

Is it a regression?

Debug Output

From the Execute to the failure there was only 50 secs wait while spinning a PRO/classic warehouse may take up to 5 mins sometimes

2024-11-13T23:52:51.229-0600 [INFO] provider.terraform-provider-databricks_v1.58.0: [INFO] Executing Sql: CREATE TABLE test_catalog.test-schema.usageEvents (key string, value string, partition int, offset bigint, timestamp timestamp)

databricks_sql_table.event_table: Still creating... [50s elapsed]

2024-11-13T23:53:41.239-0600 [DEBUG] provider.terraform-provider-databricks_v1.58.0: POST /api/2.0/sql/statements/

{ "on_wait_timeout": "CANCEL", "statement": "CREATE TABLE test_catalog.test-schema.quickstart_table (id int, name string COMMENT 'name of thing')\nUSING DELTA\nCOMMENT 'this table is managed by terraform';", "wait_timeout": "50s", "warehouse_id": "XXXXXXXXXXXXXX"" }

2024-11-13T23:53:41.261-0600 [ERROR] vertex "databricks_sql_table.event_table" error: cannot create sql table: Post "https://XXXXXXXX.cloud.databricks.com/api/2.0/sql/statements/": context deadline exceeded

Important Factoids

We would like a longer time out or some retries for the context deadline exceeded error

Would you like to implement a fix?