Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions acceptance/bundle/lifecycle/prevent-destroy/databricks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bundle:
name: prevent-destroy

include:
- resources/*.yml
67 changes: 67 additions & 0 deletions acceptance/bundle/lifecycle/prevent-destroy/out.direct-exp.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@

>>> musterr [CLI] bundle destroy --auto-approve
Error: resource my_pipelines has lifecycle.prevent_destroy set, but the plan calls for this resource to be recreated or destroyed. To avoid this error, disable lifecycle.prevent_destroy for pipelines.my_pipelines
resource my_schema has lifecycle.prevent_destroy set, but the plan calls for this resource to be recreated or destroyed. To avoid this error, disable lifecycle.prevent_destroy for schemas.my_schema


Exit code (musterr): 1

>>> errcode [CLI] bundle plan
recreate pipelines.my_pipelines

>>> musterr [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/prevent-destroy/default/files...
Error: resource my_pipelines has lifecycle.prevent_destroy set, but the plan calls for this resource to be recreated or destroyed. To avoid this error, disable lifecycle.prevent_destroy for pipelines.my_pipelines


Exit code (musterr): 1

>>> errcode [CLI] bundle plan
recreate pipelines.my_pipelines
recreate schemas.my_schema

>>> musterr [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/prevent-destroy/default/files...
Error: resource my_pipelines has lifecycle.prevent_destroy set, but the plan calls for this resource to be recreated or destroyed. To avoid this error, disable lifecycle.prevent_destroy for pipelines.my_pipelines
resource my_schema has lifecycle.prevent_destroy set, but the plan calls for this resource to be recreated or destroyed. To avoid this error, disable lifecycle.prevent_destroy for schemas.my_schema


Exit code (musterr): 1

>>> errcode [CLI] bundle plan
recreate pipelines.my_pipelines
recreate schemas.my_schema

>>> [CLI] bundle deploy --auto-approve
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/prevent-destroy/default/files...

This action will result in the deletion or recreation of the following UC schemas. Any underlying data may be lost:
recreate schema my_schema

This action will result in the deletion or recreation of the following Lakeflow Declarative Pipelines along with the
Streaming Tables (STs) and Materialized Views (MVs) managed by them. Recreating the pipelines will
restore the defined STs and MVs through full refresh. Note that recreation is necessary when pipeline
properties such as the 'catalog' or 'storage' are changed:
recreate pipeline my_pipelines
Deploying resources...
Updating deployment state...
Deployment complete!

>>> errcode [CLI] bundle plan
delete pipelines.my_pipelines
delete schemas.my_schema

>>> [CLI] bundle deploy --auto-approve
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/prevent-destroy/default/files...

This action will result in the deletion or recreation of the following UC schemas. Any underlying data may be lost:
delete schema my_schema

This action will result in the deletion or recreation of the following Lakeflow Declarative Pipelines along with the
Streaming Tables (STs) and Materialized Views (MVs) managed by them. Recreating the pipelines will
restore the defined STs and MVs through full refresh. Note that recreation is necessary when pipeline
properties such as the 'catalog' or 'storage' are changed:
delete pipeline my_pipelines
Deploying resources...
Updating deployment state...
Deployment complete!
155 changes: 155 additions & 0 deletions acceptance/bundle/lifecycle/prevent-destroy/out.terraform.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@

>>> musterr [CLI] bundle destroy --auto-approve
Error: exit status 1

Error: Instance cannot be destroyed

on bundle.tf.json line 15, in resource.databricks_pipeline:
15: "my_pipelines": {

Resource databricks_pipeline.my_pipelines has lifecycle.prevent_destroy set,
but the plan calls for this resource to be destroyed. To avoid this error and
continue with the plan, either disable lifecycle.prevent_destroy or reduce
the scope of the plan using the -target flag.

Error: Instance cannot be destroyed

on bundle.tf.json line 38, in resource.databricks_schema:
38: "my_schema": {

Resource databricks_schema.my_schema has lifecycle.prevent_destroy set, but
the plan calls for this resource to be destroyed. To avoid this error and
continue with the plan, either disable lifecycle.prevent_destroy or reduce
the scope of the plan using the -target flag.



Exit code (musterr): 1

>>> errcode [CLI] bundle plan
Error: exit status 1

Error: Instance cannot be destroyed

on bundle.tf.json line 15, in resource.databricks_pipeline:
15: "my_pipelines": {

Resource databricks_pipeline.my_pipelines has lifecycle.prevent_destroy set,
but the plan calls for this resource to be destroyed. To avoid this error and
continue with the plan, either disable lifecycle.prevent_destroy or reduce
the scope of the plan using the -target flag.



Exit code: 1

>>> musterr [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/prevent-destroy/default/files...
Error: exit status 1

Error: Instance cannot be destroyed

on bundle.tf.json line 15, in resource.databricks_pipeline:
15: "my_pipelines": {

Resource databricks_pipeline.my_pipelines has lifecycle.prevent_destroy set,
but the plan calls for this resource to be destroyed. To avoid this error and
continue with the plan, either disable lifecycle.prevent_destroy or reduce
the scope of the plan using the -target flag.



Exit code (musterr): 1

>>> errcode [CLI] bundle plan
Error: exit status 1

Error: Instance cannot be destroyed

on bundle.tf.json line 15, in resource.databricks_pipeline:
15: "my_pipelines": {

Resource databricks_pipeline.my_pipelines has lifecycle.prevent_destroy set,
but the plan calls for this resource to be destroyed. To avoid this error and
continue with the plan, either disable lifecycle.prevent_destroy or reduce
the scope of the plan using the -target flag.

Error: Instance cannot be destroyed

on bundle.tf.json line 38, in resource.databricks_schema:
38: "my_schema": {

Resource databricks_schema.my_schema has lifecycle.prevent_destroy set, but
the plan calls for this resource to be destroyed. To avoid this error and
continue with the plan, either disable lifecycle.prevent_destroy or reduce
the scope of the plan using the -target flag.



Exit code: 1

>>> musterr [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/prevent-destroy/default/files...
Error: exit status 1

Error: Instance cannot be destroyed

on bundle.tf.json line 15, in resource.databricks_pipeline:
15: "my_pipelines": {

Resource databricks_pipeline.my_pipelines has lifecycle.prevent_destroy set,
but the plan calls for this resource to be destroyed. To avoid this error and
continue with the plan, either disable lifecycle.prevent_destroy or reduce
the scope of the plan using the -target flag.

Error: Instance cannot be destroyed

on bundle.tf.json line 38, in resource.databricks_schema:
38: "my_schema": {

Resource databricks_schema.my_schema has lifecycle.prevent_destroy set, but
the plan calls for this resource to be destroyed. To avoid this error and
continue with the plan, either disable lifecycle.prevent_destroy or reduce
the scope of the plan using the -target flag.



Exit code (musterr): 1

>>> errcode [CLI] bundle plan
recreate pipelines.my_pipelines
recreate schemas.my_schema

>>> [CLI] bundle deploy --auto-approve
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/prevent-destroy/default/files...

This action will result in the deletion or recreation of the following UC schemas. Any underlying data may be lost:
recreate schema my_schema

This action will result in the deletion or recreation of the following Lakeflow Declarative Pipelines along with the
Streaming Tables (STs) and Materialized Views (MVs) managed by them. Recreating the pipelines will
restore the defined STs and MVs through full refresh. Note that recreation is necessary when pipeline
properties such as the 'catalog' or 'storage' are changed:
recreate pipeline my_pipelines
Deploying resources...
Updating deployment state...
Deployment complete!

>>> errcode [CLI] bundle plan
delete pipelines.my_pipelines
delete schemas.my_schema

>>> [CLI] bundle deploy --auto-approve
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/prevent-destroy/default/files...

This action will result in the deletion or recreation of the following UC schemas. Any underlying data may be lost:
delete schema my_schema

This action will result in the deletion or recreation of the following Lakeflow Declarative Pipelines along with the
Streaming Tables (STs) and Materialized Views (MVs) managed by them. Recreating the pipelines will
restore the defined STs and MVs through full refresh. Note that recreation is necessary when pipeline
properties such as the 'catalog' or 'storage' are changed:
delete pipeline my_pipelines
Deploying resources...
Updating deployment state...
Deployment complete!
5 changes: 5 additions & 0 deletions acceptance/bundle/lifecycle/prevent-destroy/out.test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Local = true
Cloud = false

[EnvMatrix]
DATABRICKS_CLI_DEPLOYMENT = ["terraform", "direct-exp"]
17 changes: 17 additions & 0 deletions acceptance/bundle/lifecycle/prevent-destroy/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

>>> [CLI] bundle validate
Name: prevent-destroy
Target: default
Workspace:
User: [USERNAME]
Path: /Workspace/Users/[USERNAME]/.bundle/prevent-destroy/default

Validation OK!

>>> [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/prevent-destroy/default/files...
Deploying resources...
Updating deployment state...
Deployment complete!

>>> errcode [CLI] bundle plan
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
resources:
pipelines:
my_pipelines:
name: "test-pipeline"
libraries:
- notebook:
path: "../test-notebook.py"
lifecycle:
prevent_destroy: true
schema: test-schema
catalog: main
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
resources:
schemas:
my_schema:
catalog_name: "test-catalog"
name: test-schema
lifecycle:
prevent_destroy: true
30 changes: 30 additions & 0 deletions acceptance/bundle/lifecycle/prevent-destroy/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
trace $CLI bundle validate

trace $CLI bundle deploy

trace errcode $CLI bundle plan
trace musterr $CLI bundle destroy --auto-approve >>out.$DATABRICKS_CLI_DEPLOYMENT.txt 2>&1

# Changing the catalog name, deploy must fail because pipeline will be recreated
update_file.py resources/pipeline.yml 'catalog: main' 'catalog: mainnew'
trace errcode $CLI bundle plan >>out.$DATABRICKS_CLI_DEPLOYMENT.txt 2>&1
trace musterr $CLI bundle deploy >>out.$DATABRICKS_CLI_DEPLOYMENT.txt 2>&1

# Changing the schema name, deploy must fail because schema will be recreated
update_file.py resources/schema.yml 'name: test-schema' 'name: test-schema-new'
trace errcode $CLI bundle plan >>out.$DATABRICKS_CLI_DEPLOYMENT.txt 2>&1
trace musterr $CLI bundle deploy >>out.$DATABRICKS_CLI_DEPLOYMENT.txt 2>&1

# Removing the prevent_destroy, deploy must succeed
update_file.py resources/pipeline.yml 'prevent_destroy: true' 'prevent_destroy: false'
update_file.py resources/schema.yml 'prevent_destroy: true' 'prevent_destroy: false'
trace errcode $CLI bundle plan >>out.$DATABRICKS_CLI_DEPLOYMENT.txt 2>&1
trace $CLI bundle deploy --auto-approve >>out.$DATABRICKS_CLI_DEPLOYMENT.txt 2>&1
update_file.py resources/pipeline.yml 'prevent_destroy: false' 'prevent_destroy: true'
update_file.py resources/schema.yml 'prevent_destroy: false' 'prevent_destroy: true'


# Removing the pipeline and schema, deploy must succeed
rm resources/pipeline.yml resources/schema.yml
trace errcode $CLI bundle plan >>out.$DATABRICKS_CLI_DEPLOYMENT.txt 2>&1
trace $CLI bundle deploy --auto-approve >>out.$DATABRICKS_CLI_DEPLOYMENT.txt 2>&1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Databricks notebook source

print("Hello, World!")
32 changes: 32 additions & 0 deletions acceptance/bundle/lifecycle/prevent-destroy/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
EnvVaryOutput = "DATABRICKS_CLI_DEPLOYMENT"

Ignore = [
".databricks"
]

[[Server]]
Pattern = "POST /api/2.0/serving-endpoints"
Response.Body = '''
{
"id": "test-endpoint-6260d50f-e8ff-4905-8f28-812345678903",
"name": "test-endpoint-6260d50f-e8ff-4905-8f28-812345678903"
}
'''

[[Server]]
Pattern = "GET /api/2.0/serving-endpoints/"


[[Server]]
Pattern = "GET /api/2.0/serving-endpoints/test-endpoint-6260d50f-e8ff-4905-8f28-812345678903"
Response.Body = '''
{
"id": "test-endpoint-6260d50f-e8ff-4905-8f28-812345678903",
"permission_level": "CAN_MANAGE",
"route_optimized": false,
"state": {
"config_update": "NOT_UPDATING",
"ready": "NOT_READY"
}
}
'''
2 changes: 2 additions & 0 deletions acceptance/bundle/lifecycle/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Local = true
Cloud = false
Loading
Loading