-
Notifications
You must be signed in to change notification settings - Fork 177
Added support for lifecycle.started for SQL warehouses #5348
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| bundle: | ||
| name: lifecycle-started-terraform-error-$UNIQUE_NAME | ||
|
|
||
| workspace: | ||
| root_path: ~/.bundle/$UNIQUE_NAME | ||
|
|
||
| resources: | ||
| sql_warehouses: | ||
| mywarehouse: | ||
| name: my-warehouse-$UNIQUE_NAME | ||
| cluster_size: "Medium" | ||
| lifecycle: | ||
| started: true |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
|
|
||
| === bundle plan fails with lifecycle.started on terraform engine | ||
| >>> errcode [CLI] bundle plan | ||
| Error: lifecycle.started is only supported in direct deployment mode | ||
| in databricks.yml:13:18 | ||
|
|
||
|
|
||
| Exit code: 1 | ||
|
|
||
| === bundle deploy fails with lifecycle.started on terraform engine | ||
| >>> errcode [CLI] bundle deploy | ||
| Error: lifecycle.started is only supported in direct deployment mode | ||
| in databricks.yml:13:18 | ||
|
|
||
|
|
||
| Exit code: 1 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| envsubst < databricks.yml.tmpl > databricks.yml | ||
|
|
||
| title "bundle plan fails with lifecycle.started on terraform engine" | ||
| trace errcode $CLI bundle plan | ||
|
|
||
| title "bundle deploy fails with lifecycle.started on terraform engine" | ||
| trace errcode $CLI bundle deploy | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| Local = true | ||
| Cloud = true | ||
| RecordRequests = false | ||
|
|
||
| Ignore = [".databricks", "databricks.yml"] | ||
|
|
||
| [EnvMatrix] | ||
| DATABRICKS_BUNDLE_ENGINE = ["terraform"] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| bundle: | ||
| name: lifecycle-started-toggle-$UNIQUE_NAME | ||
|
|
||
| workspace: | ||
| root_path: ~/.bundle/$UNIQUE_NAME | ||
|
|
||
| resources: | ||
| sql_warehouses: | ||
| mywarehouse: | ||
| name: $UNIQUE_NAME | ||
| cluster_size: "Medium" | ||
| lifecycle: | ||
| started: false |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
|
|
||
| === Deploy with started=false: warehouse created and then stopped | ||
| >>> errcode [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
|
|
||
| >>> print_requests.py //sql/warehouses | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/sql/warehouses", | ||
| "body": { | ||
| "auto_stop_mins": 120, | ||
| "cluster_size": "Medium", | ||
| "enable_photon": true, | ||
| "max_num_clusters": 1, | ||
| "name": "[UNIQUE_NAME]", | ||
| "spot_instance_policy": "COST_OPTIMIZED" | ||
| } | ||
| } | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/sql/warehouses/[UUID]/stop" | ||
| } | ||
|
|
||
| >>> errcode [CLI] warehouses get [UUID] | ||
| "STOPPED" | ||
|
|
||
| === Toggle started=false -> started=true: only Start should be called, no Edit | ||
| >>> update_file.py databricks.yml started: false started: true | ||
|
|
||
| >>> errcode [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
|
|
||
| >>> print_requests.py //sql/warehouses | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/sql/warehouses/[UUID]/start" | ||
| } | ||
|
|
||
| >>> errcode [CLI] warehouses get [UUID] | ||
| "RUNNING" | ||
|
|
||
| === Toggle started=true -> started=false: only Stop should be called, no Edit | ||
| >>> update_file.py databricks.yml started: true started: false | ||
|
|
||
| >>> errcode [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
|
|
||
| >>> print_requests.py //sql/warehouses | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/sql/warehouses/[UUID]/stop" | ||
| } | ||
|
|
||
| >>> errcode [CLI] warehouses get [UUID] | ||
| "STOPPED" | ||
|
|
||
| >>> [CLI] bundle destroy --auto-approve | ||
| The following resources will be deleted: | ||
| delete resources.sql_warehouses.mywarehouse | ||
|
|
||
| All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME] | ||
|
|
||
| Deleting files... | ||
| Destroy complete! |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| envsubst < databricks.yml.tmpl > databricks.yml | ||
|
|
||
| cleanup() { | ||
| trace $CLI bundle destroy --auto-approve | ||
| rm -f out.requests.txt | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
| title "Deploy with started=false: warehouse created and then stopped" | ||
| trace errcode $CLI bundle deploy | ||
| WAREHOUSE_ID=$($CLI bundle summary -o json | jq -r '.resources.sql_warehouses.mywarehouse.id') | ||
| trace print_requests.py //sql/warehouses | ||
| rm -f out.requests.txt | ||
| { trace errcode $CLI warehouses get "$WAREHOUSE_ID" | jq '.state'; } || true | ||
|
|
||
| title "Toggle started=false -> started=true: only Start should be called, no Edit" | ||
| trace update_file.py databricks.yml "started: false" "started: true" | ||
| trace errcode $CLI bundle deploy | ||
| trace print_requests.py //sql/warehouses | ||
| rm -f out.requests.txt | ||
| { trace errcode $CLI warehouses get "$WAREHOUSE_ID" | jq '.state'; } || true | ||
|
|
||
| title "Toggle started=true -> started=false: only Stop should be called, no Edit" | ||
| trace update_file.py databricks.yml "started: true" "started: false" | ||
| trace errcode $CLI bundle deploy | ||
| trace print_requests.py //sql/warehouses | ||
| rm -f out.requests.txt | ||
| { trace errcode $CLI warehouses get "$WAREHOUSE_ID" | jq '.state'; } || true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| Local = true | ||
| Cloud = true | ||
| RecordRequests = true | ||
|
|
||
| Ignore = [".databricks", "databricks.yml"] | ||
|
|
||
| [[Repls]] | ||
| Old = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}" | ||
| New = "[UUID]" | ||
|
|
||
| [EnvMatrix] | ||
| DATABRICKS_BUNDLE_ENGINE = ["direct"] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| bundle: | ||
| name: lifecycle-started-$UNIQUE_NAME | ||
|
|
||
| workspace: | ||
| root_path: ~/.bundle/$UNIQUE_NAME | ||
|
|
||
| resources: | ||
| sql_warehouses: | ||
| mywarehouse: | ||
| name: $UNIQUE_NAME | ||
| cluster_size: "Medium" | ||
| lifecycle: | ||
| started: true |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
|
|
||
| === Deploy with started=true: warehouse created and running | ||
| >>> errcode [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
|
|
||
| >>> print_requests.py //sql/warehouses | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/sql/warehouses", | ||
| "body": { | ||
| "auto_stop_mins": 120, | ||
| "cluster_size": "Medium", | ||
| "enable_photon": true, | ||
| "max_num_clusters": 1, | ||
| "name": "[UNIQUE_NAME]", | ||
| "spot_instance_policy": "COST_OPTIMIZED" | ||
| } | ||
| } | ||
|
|
||
| >>> errcode [CLI] warehouses get [UUID] | ||
| "RUNNING" | ||
|
|
||
| === Stop warehouse externally while config says started=true: plan detects drift | ||
| >>> errcode [CLI] warehouses stop [UUID] | ||
| "STOPPED" | ||
|
|
||
| >>> [CLI] bundle plan | ||
| update sql_warehouses.mywarehouse | ||
|
|
||
| Plan: 0 to add, 1 to change, 0 to delete, 0 unchanged | ||
|
|
||
| === Deploy fixes the drift: warehouse restarted | ||
| >>> errcode [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
|
|
||
| >>> print_requests.py //sql/warehouses | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/sql/warehouses/[UUID]/stop" | ||
| } | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/sql/warehouses/[UUID]/start" | ||
| } | ||
|
|
||
| >>> errcode [CLI] warehouses get [UUID] | ||
| "RUNNING" | ||
|
|
||
| === Deploy with started=false while warehouse is stopped: warehouse stays stopped | ||
| >>> errcode [CLI] warehouses stop [UUID] | ||
| "STOPPED" | ||
|
|
||
| >>> update_file.py databricks.yml started: true started: false | ||
|
|
||
| >>> errcode [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
|
|
||
| >>> print_requests.py //sql/warehouses | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/sql/warehouses/[UUID]/stop" | ||
| } | ||
|
|
||
| >>> errcode [CLI] warehouses get [UUID] | ||
| "STOPPED" | ||
|
|
||
| === Deploy with started=true: warehouse restarted | ||
| >>> update_file.py databricks.yml started: false started: true | ||
|
|
||
| >>> errcode [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
|
|
||
| >>> print_requests.py //sql/warehouses | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/sql/warehouses/[UUID]/start" | ||
| } | ||
|
|
||
| >>> errcode [CLI] warehouses get [UUID] | ||
| "RUNNING" | ||
|
|
||
| >>> [CLI] bundle destroy --auto-approve | ||
| The following resources will be deleted: | ||
| delete resources.sql_warehouses.mywarehouse | ||
|
|
||
| All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME] | ||
|
|
||
| Deleting files... | ||
| Destroy complete! |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| envsubst < databricks.yml.tmpl > databricks.yml | ||
|
|
||
| cleanup() { | ||
| trace $CLI bundle destroy --auto-approve | ||
| rm -f out.requests.txt | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
| title "Deploy with started=true: warehouse created and running" | ||
| trace errcode $CLI bundle deploy | ||
| WAREHOUSE_ID=$($CLI bundle summary -o json | jq -r '.resources.sql_warehouses.mywarehouse.id') | ||
| trace print_requests.py //sql/warehouses | ||
| rm -f out.requests.txt | ||
| { trace errcode $CLI warehouses get "$WAREHOUSE_ID" | jq '.state'; } || true | ||
|
|
||
| title "Stop warehouse externally while config says started=true: plan detects drift" | ||
| { trace errcode $CLI warehouses stop "$WAREHOUSE_ID" | jq '.state'; } || true | ||
| trace $CLI bundle plan | ||
|
|
||
| title "Deploy fixes the drift: warehouse restarted" | ||
| trace errcode $CLI bundle deploy | ||
| trace print_requests.py //sql/warehouses | ||
| rm -f out.requests.txt | ||
| { trace errcode $CLI warehouses get "$WAREHOUSE_ID" | jq '.state'; } || true | ||
|
|
||
| title "Deploy with started=false while warehouse is stopped: warehouse stays stopped" | ||
| { trace errcode $CLI warehouses stop "$WAREHOUSE_ID" | jq '.state'; } || true | ||
| trace update_file.py databricks.yml "started: true" "started: false" | ||
| trace errcode $CLI bundle deploy | ||
| trace print_requests.py //sql/warehouses | ||
| rm -f out.requests.txt | ||
| { trace errcode $CLI warehouses get "$WAREHOUSE_ID" | jq '.state'; } || true | ||
|
|
||
| title "Deploy with started=true: warehouse restarted" | ||
| trace update_file.py databricks.yml "started: false" "started: true" | ||
| trace errcode $CLI bundle deploy | ||
| trace print_requests.py //sql/warehouses | ||
| rm -f out.requests.txt | ||
| { trace errcode $CLI warehouses get "$WAREHOUSE_ID" | jq '.state'; } || true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| Local = true | ||
| Cloud = true | ||
| RecordRequests = true | ||
|
|
||
| Ignore = [".databricks", "databricks.yml"] | ||
|
|
||
| [[Repls]] | ||
| Old = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}" | ||
| New = "[UUID]" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if you know the UUID of the resources in question, you can add them to replacement dynamically with add_repl.py. It's better, since it's targeted, function as assert that id is correct, and distinguishes different ids. |
||
|
|
||
| [EnvMatrix] | ||
| DATABRICKS_BUNDLE_ENGINE = ["direct"] | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we also have 'musterr' helper to assert that it indeed fails.