From 0fcadd07da2f89e44fc5a455ccea84e19e112243 Mon Sep 17 00:00:00 2001 From: "denis.bilenko" Date: Tue, 24 Nov 2026 15:09:50 +0000 Subject: [PATCH 1/2] acc: record that a rejected delete drops the resource from state in bundle/destroy/delete-error When the backend rejects a delete with an error other than not-found or permission-denied, deploy and destroy without deployment history drop the resource from state and succeed, leaving it in the workspace untracked. Co-authored-by: Isaac --- .../destroy/delete-error/databricks.yml.tmpl | 9 +++++ .../bundle/destroy/delete-error/out.test.toml | 2 ++ .../bundle/destroy/delete-error/output.txt | 36 +++++++++++++++++++ acceptance/bundle/destroy/delete-error/script | 19 ++++++++++ .../bundle/destroy/delete-error/test.toml | 9 +++++ 5 files changed, 75 insertions(+) create mode 100644 acceptance/bundle/destroy/delete-error/databricks.yml.tmpl create mode 100644 acceptance/bundle/destroy/delete-error/out.test.toml create mode 100644 acceptance/bundle/destroy/delete-error/output.txt create mode 100644 acceptance/bundle/destroy/delete-error/script create mode 100644 acceptance/bundle/destroy/delete-error/test.toml diff --git a/acceptance/bundle/destroy/delete-error/databricks.yml.tmpl b/acceptance/bundle/destroy/delete-error/databricks.yml.tmpl new file mode 100644 index 00000000000..4d4606862fe --- /dev/null +++ b/acceptance/bundle/destroy/delete-error/databricks.yml.tmpl @@ -0,0 +1,9 @@ +bundle: + name: delete-error-$UNIQUE_NAME + +resources: + jobs: + foo: + name: foo-$UNIQUE_NAME + bar: + name: bar-$UNIQUE_NAME diff --git a/acceptance/bundle/destroy/delete-error/out.test.toml b/acceptance/bundle/destroy/delete-error/out.test.toml new file mode 100644 index 00000000000..2ab253adc73 --- /dev/null +++ b/acceptance/bundle/destroy/delete-error/out.test.toml @@ -0,0 +1,2 @@ +Cloud = false +EnvMatrix.DMS = [] diff --git a/acceptance/bundle/destroy/delete-error/output.txt b/acceptance/bundle/destroy/delete-error/output.txt new file mode 100644 index 00000000000..dbac1f959cd --- /dev/null +++ b/acceptance/bundle/destroy/delete-error/output.txt @@ -0,0 +1,36 @@ + +>>> [CLI] bundle deploy +Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/delete-error-[UNIQUE_NAME]/default/files... +Created jobs.bar +Created jobs.foo +Files: 2 uploaded, 0 deleted +Resources: 2 created, 0 changed, 0 deleted, 0 unchanged + +=== deploy: removing bar from config, its delete is rejected with 400 + +>>> [CLI] bundle deploy +Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/delete-error-[UNIQUE_NAME]/default/files... +Deleted jobs.bar +Files: 1 uploaded, 0 deleted +Resources: 0 created, 0 changed, 1 deleted, 1 unchanged + +>>> [CLI] jobs get [BAR_ID] +bar-[UNIQUE_NAME] + +>>> print_state.py +resources.jobs.foo + +=== destroy: the delete of foo is rejected with 400 + +>>> [CLI] bundle destroy --auto-approve +The following resources will be deleted: + delete resources.jobs.foo + +All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/delete-error-[UNIQUE_NAME]/default + +Destroy: 1 deleted + +>>> [CLI] jobs get [FOO_ID] +foo-[UNIQUE_NAME] + +>>> find.py \.databricks/.*resources.*\.json diff --git a/acceptance/bundle/destroy/delete-error/script b/acceptance/bundle/destroy/delete-error/script new file mode 100644 index 00000000000..aae9ab2a922 --- /dev/null +++ b/acceptance/bundle/destroy/delete-error/script @@ -0,0 +1,19 @@ +envsubst < databricks.yml.tmpl > databricks.yml +trace $CLI bundle deploy +foo_id=$(read_id.py foo) +bar_id=$(read_id.py bar) + +title "deploy: removing bar from config, its delete is rejected with 400" +update_file.py databricks.yml " bar: + name: bar-$UNIQUE_NAME +" "" +fault.py "POST /api/2.2/jobs/delete" 400 0 1 INVALID_PARAMETER_VALUE +errcode trace $CLI bundle deploy +trace $CLI jobs get $bar_id | jq -r .settings.name +trace print_state.py | jq -r '.state | keys[]' + +title "destroy: the delete of foo is rejected with 400" +fault.py --body-contains "\"job_id\":$foo_id}" "POST /api/2.2/jobs/delete" 400 0 1 INVALID_PARAMETER_VALUE +errcode trace $CLI bundle destroy --auto-approve +trace $CLI jobs get $foo_id | jq -r .settings.name +trace find.py '\.databricks/.*resources.*\.json' diff --git a/acceptance/bundle/destroy/delete-error/test.toml b/acceptance/bundle/destroy/delete-error/test.toml new file mode 100644 index 00000000000..5295644db26 --- /dev/null +++ b/acceptance/bundle/destroy/delete-error/test.toml @@ -0,0 +1,9 @@ +Cloud = false +Badness = "When the backend rejects a delete with an error other than not-found or permission-denied, deploy and destroy drop the resource from state and succeed, so the job stays in the workspace untracked. They should fail with the delete error and keep the resource in state, as the DMS=true run does." + +# The DMS=true run already fails on the rejected delete, so it is excluded until both agree. +EnvMatrix.DMS = [] + +Ignore = [ + "databricks.yml", +] From dc4a6d80c483255c6ef818dac466af3e7fd1dc32 Mon Sep 17 00:00:00 2001 From: "denis.bilenko" Date: Tue, 24 Nov 2026 16:16:08 +0000 Subject: [PATCH 2/2] acc: use gron.py and inherited settings in bundle/destroy/delete-error Co-authored-by: Isaac --- acceptance/bundle/destroy/delete-error/output.txt | 6 +++--- acceptance/bundle/destroy/delete-error/script | 6 +++--- acceptance/bundle/destroy/delete-error/test.toml | 7 +------ 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/acceptance/bundle/destroy/delete-error/output.txt b/acceptance/bundle/destroy/delete-error/output.txt index dbac1f959cd..9bcc24e73d7 100644 --- a/acceptance/bundle/destroy/delete-error/output.txt +++ b/acceptance/bundle/destroy/delete-error/output.txt @@ -15,10 +15,10 @@ Files: 1 uploaded, 0 deleted Resources: 0 created, 0 changed, 1 deleted, 1 unchanged >>> [CLI] jobs get [BAR_ID] -bar-[UNIQUE_NAME] +json.settings.name = "bar-[UNIQUE_NAME]"; >>> print_state.py -resources.jobs.foo +json.state.resources.jobs.foo.__id__ = "[FOO_ID]"; === destroy: the delete of foo is rejected with 400 @@ -31,6 +31,6 @@ All files and directories at the following location will be deleted: /Workspace/ Destroy: 1 deleted >>> [CLI] jobs get [FOO_ID] -foo-[UNIQUE_NAME] +json.settings.name = "foo-[UNIQUE_NAME]"; >>> find.py \.databricks/.*resources.*\.json diff --git a/acceptance/bundle/destroy/delete-error/script b/acceptance/bundle/destroy/delete-error/script index aae9ab2a922..f020cc4be9c 100644 --- a/acceptance/bundle/destroy/delete-error/script +++ b/acceptance/bundle/destroy/delete-error/script @@ -9,11 +9,11 @@ update_file.py databricks.yml " bar: " "" fault.py "POST /api/2.2/jobs/delete" 400 0 1 INVALID_PARAMETER_VALUE errcode trace $CLI bundle deploy -trace $CLI jobs get $bar_id | jq -r .settings.name -trace print_state.py | jq -r '.state | keys[]' +trace $CLI jobs get $bar_id | gron.py | grep settings.name +trace print_state.py | gron.py | grep __id__ title "destroy: the delete of foo is rejected with 400" fault.py --body-contains "\"job_id\":$foo_id}" "POST /api/2.2/jobs/delete" 400 0 1 INVALID_PARAMETER_VALUE errcode trace $CLI bundle destroy --auto-approve -trace $CLI jobs get $foo_id | jq -r .settings.name +trace $CLI jobs get $foo_id | gron.py | grep settings.name trace find.py '\.databricks/.*resources.*\.json' diff --git a/acceptance/bundle/destroy/delete-error/test.toml b/acceptance/bundle/destroy/delete-error/test.toml index 5295644db26..fd09ad4aa2e 100644 --- a/acceptance/bundle/destroy/delete-error/test.toml +++ b/acceptance/bundle/destroy/delete-error/test.toml @@ -1,9 +1,4 @@ -Cloud = false -Badness = "When the backend rejects a delete with an error other than not-found or permission-denied, deploy and destroy drop the resource from state and succeed, so the job stays in the workspace untracked. They should fail with the delete error and keep the resource in state, as the DMS=true run does." +Badness = "When the backend rejects a delete and a re-read does not confirm the resource is gone, deploy and destroy drop the resource from state and succeed, so the job stays in the workspace untracked. They should fail with the delete error and keep the resource in state, as the DMS=true run does." # The DMS=true run already fails on the rejected delete, so it is excluded until both agree. EnvMatrix.DMS = [] - -Ignore = [ - "databricks.yml", -]