Skip to content
Open
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
1 change: 1 addition & 0 deletions .nextchanges/bundles/accurate-resource-summary-counts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Fix bundle `deploy` and `destroy` summaries to report partial successes and resource failures, including completed deletions when replacement creation fails. ([#7006](https://github.com/databricks/cli/pull/7006))
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/defaul
Error: cannot create resources.volumes.volume1: create returned an empty resource id

Files: 0 uploaded, 0 deleted
Resources: 0 created, 0 changed, 0 deleted, 0 unchanged, 1 failed

=== The failed create does not save resource state

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/defaul
Error: cannot update_id resources.volumes.volume1: update returned an empty resource id

Files: 0 uploaded, 0 deleted
Resources: 0 created, 0 changed, 0 deleted, 0 unchanged, 1 failed

=== The failed rename preserves the original ID and state

Expand Down
16 changes: 16 additions & 0 deletions acceptance/bundle/deploy/summary-on-error/databricks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
bundle:
name: test-deploy-summary-on-error

resources:
jobs:
# Chained job_01 <- job_02 <- job_03 via id references, so deploy creates them in a
# fixed order (job_01, job_02, job_03). Independent jobs would create in parallel,
# making both the faulted create and the error output vary per run.
job_01:
name: job-01
job_02:
name: job-02
description: needs ${resources.jobs.job_01.id}
job_03:
name: job-03
description: needs ${resources.jobs.job_02.id}
2 changes: 2 additions & 0 deletions acceptance/bundle/deploy/summary-on-error/out.test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Cloud = false
EnvMatrix.DMS = ["", "true"]
19 changes: 19 additions & 0 deletions acceptance/bundle/deploy/summary-on-error/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

=== Deploy three chained jobs; the second create fails

>>> fault.py POST /api/2.2/jobs/create 400 1 1 INVALID_PARAMETER_VALUE

>>> musterr [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-deploy-summary-on-error/default/files...
Created jobs.job_01
Error: cannot create resources.jobs.job_02: Fault injected by test. (400 INVALID_PARAMETER_VALUE)

Endpoint: POST [DATABRICKS_URL]/api/2.2/jobs/create
HTTP Status: 400 Bad Request
API error_code: INVALID_PARAMETER_VALUE
API message: Fault injected by test.

Error: cannot create resources.jobs.job_03: dependency failed: resources.jobs.job_02

Files: 1 uploaded, 0 deleted
Resources: 1 created, 0 changed, 0 deleted, 0 unchanged, 2 failed
6 changes: 6 additions & 0 deletions acceptance/bundle/deploy/summary-on-error/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
title "Deploy three chained jobs; the second create fails"
# Creates run in chain order (job_01, job_02, job_03); faulting the second create makes
# job_01 succeed, job_02 fail, and job_03 skip because its dependency failed. The summary
# reports the accurate counts (1 created, 2 failed) rather than the planned 3 created.
trace fault.py "POST /api/2.2/jobs/create" 400 1 1 INVALID_PARAMETER_VALUE
trace musterr $CLI bundle deploy
4 changes: 4 additions & 0 deletions acceptance/bundle/deploy/summary-on-error/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# fault.py registers its rule on the fake server, which a real workspace does not have.
Cloud = false

Ignore = [".databricks"]
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ API error_code: ALREADY_EXISTS
API message: Data API is already enabled for this database

Files: 2 uploaded, 0 deleted
Resources: 0 created, 0 changed, 0 deleted, 0 unchanged, 1 failed

=== Bind adopts the existing Data API

Expand Down
16 changes: 16 additions & 0 deletions acceptance/bundle/destroy/summary-on-error/databricks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
bundle:
name: test-destroy-summary-on-error

resources:
jobs:
# Chained job_01 <- job_02 <- job_03 via id references, so destroy deletes them in a
# fixed order (children first: job_03, job_02, job_01). Independent jobs would delete
# in parallel, making both the faulted delete and the error output vary per run.
job_01:
name: job-01
job_02:
name: job-02
description: needs ${resources.jobs.job_01.id}
job_03:
name: job-03
description: needs ${resources.jobs.job_02.id}
2 changes: 2 additions & 0 deletions acceptance/bundle/destroy/summary-on-error/out.test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Cloud = false
EnvMatrix.DMS = ["true"]
31 changes: 31 additions & 0 deletions acceptance/bundle/destroy/summary-on-error/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

=== Deploy three chained jobs

>>> [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-destroy-summary-on-error/default/files...
Created jobs.job_01
Created jobs.job_02
Created jobs.job_03
Files: 1 uploaded, 0 deleted
Resources: 3 created, 0 changed, 0 deleted, 0 unchanged

=== Destroy: report two successful deletions and one failure

>>> fault.py POST /api/2.2/jobs/delete 400 2 1 INVALID_PARAMETER_VALUE

>>> musterr [CLI] bundle destroy --auto-approve
The following resources will be deleted:
delete resources.jobs.job_01
delete resources.jobs.job_02
delete resources.jobs.job_03

All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/test-destroy-summary-on-error/default

Error: cannot delete resources.jobs.job_01: deleting id=[JOB_01_ID]: Fault injected by test. (400 INVALID_PARAMETER_VALUE)

Endpoint: POST [DATABRICKS_URL]/api/2.2/jobs/delete
HTTP Status: 400 Bad Request
API error_code: INVALID_PARAMETER_VALUE
API message: Fault injected by test.

Destroy: 2 deleted, 1 failed
11 changes: 11 additions & 0 deletions acceptance/bundle/destroy/summary-on-error/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
title "Deploy three chained jobs"
trace $CLI bundle deploy
# Mask the job IDs (the destroy error below prints job_01's) so the golden is stable.
replace_ids.py

title "Destroy: report two successful deletions and one failure"
# Deletes run children-first (job_03, job_02, job_01); faulting the third makes only
# job_01 fail while job_03 and job_02 are really deleted. The deferred summary must
# report those completed deletions even though destroy returns an error.
trace fault.py "POST /api/2.2/jobs/delete" 400 2 1 INVALID_PARAMETER_VALUE
trace musterr $CLI bundle destroy --auto-approve
8 changes: 8 additions & 0 deletions acceptance/bundle/destroy/summary-on-error/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# fault.py registers its rule on the fake server, which a real workspace does not have.
Cloud = false

# A failed resource delete only surfaces as a destroy error with deployment
# history enabled, so pin that variant to exercise the error path deterministically.
EnvMatrix.DMS = ["true"]

Ignore = [".databricks"]
1 change: 1 addition & 0 deletions acceptance/bundle/dms/failed-delete/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ HTTP Status: 400 Bad Request
API error_code: INVALID_PARAMETER_VALUE
API message: Fault injected by test.

Destroy: 0 deleted, 1 failed

>>> print_requests.py --dms //api/2.0/bundle
{
Expand Down
1 change: 1 addition & 0 deletions acceptance/bundle/dms/failed-recreate/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ API error_code: INVALID_PARAMETER_VALUE
API message: Fault injected by test.

Files: 2 uploaded, 0 deleted
Resources: 0 created, 0 changed, 1 deleted, 0 unchanged, 1 failed

>>> print_requests.py --dms //api/2.0/bundle
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ API error_code: PERMISSION_DENIED
API message: Fault injected by test.

Files: 1 uploaded, 0 deleted
Resources: 0 created, 0 changed, 0 deleted, 1 unchanged, 1 failed

=== The service lists the job with the failure

Expand Down
1 change: 1 addition & 0 deletions acceptance/bundle/dms/record-failure/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ API error_code: INVALID_PARAMETER_VALUE
API message: Node type nonexistent-node-type is not supported. Supported node types: [NODE_TYPES]

Files: 2 uploaded, 0 deleted
Resources: 0 created, 0 changed, 0 deleted, 0 unchanged, 1 failed

>>> [CLI] bundle plan -o json
{
Expand Down
1 change: 1 addition & 0 deletions acceptance/bundle/migrate/auto/apply-failure/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ API error_code: INJECTED
API message: Fault injected by test.

Files: 1 uploaded, 0 deleted
Resources: 0 created, 0 changed, 0 deleted, 0 unchanged, 1 failed

Exit code: 1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ Error: cannot create resources.jobs.bar: dependency failed: resources.jobs.foo
Error: cannot create resources.jobs.baz: dependency failed: resources.jobs.foo

Files: 0 uploaded, 0 deleted
Resources: 1 created, 0 changed, 0 deleted, 0 unchanged, 3 failed
9 changes: 8 additions & 1 deletion acceptance/bundle/resource_deps/create_error/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,14 @@ create jobs.foo

Plan: 3 to add, 0 to change, 0 to delete, 1 unchanged

=== Expecting no difference in the output between first and second deploy
=== Second deploy: only the summary differs, independent is now unchanged
--- out.deploy.txt
+++ out.deploy2.txt
@@ -12,3 +12,3 @@

Files: 0 uploaded, 0 deleted
-Resources: 1 created, 0 changed, 0 deleted, 0 unchanged, 3 failed
+Resources: 0 created, 0 changed, 0 deleted, 1 unchanged, 3 failed

>>> print_requests.py --nostamp //jobs
{
Expand Down
4 changes: 3 additions & 1 deletion acceptance/bundle/resource_deps/create_error/script
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ trace $CLI bundle plan

rm "$OUT_REQUESTS"
musterr $CLI bundle deploy -q &> out.deploy2.txt
title "Expecting no difference in the output between first and second deploy"
# The only difference is the summary: the first deploy created the independent job (1
# created), the second finds it unchanged. foo still fails and bar/baz still skip on both.
title "Second deploy: only the summary differs, independent is now unchanged"
diff.py out.deploy.txt out.deploy2.txt
rm out.deploy2.txt
trace print_requests.py --nostamp //jobs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ Created pipelines.foo
Error: cannot create resources.pipelines.bar: cannot resolve "${resources.pipelines.foo.ingestion_definition.connection_name}": ingestion_definition: cannot access nil value

Files: 4 uploaded, 0 deleted
Resources: 1 created, 0 changed, 0 deleted, 0 unchanged, 1 failed

Exit code: 1
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ Created jobs.test
Error: cannot create resources.jobs.bar: cannot resolve "${resources.jobs.test.tasks[0].new_cluster.custom_tags.missing_tag}": tasks[0].new_cluster.custom_tags.missing_tag: key "missing_tag" not found in map

Files: 4 uploaded, 0 deleted
Resources: 1 created, 0 changed, 0 deleted, 0 unchanged, 1 failed
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ API error_code: RESOURCE_ALREADY_EXISTS
API message: An app with the same name already exists: test-app-already-exists

Files: 2 uploaded, 0 deleted
Resources: 0 created, 0 changed, 0 deleted, 0 unchanged, 1 failed

>>> [CLI] apps delete test-app-already-exists
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ API error_code: INVALID_PARAMETER_VALUE
API message: Invalid input: RPC CreateCatalog Field managedcatalog.CatalogInfo.name: name "" is not a valid name. Valid names cannot contain spaces, periods, forward slashes, or control characters.

Files: 2 uploaded, 0 deleted
Resources: 0 created, 0 changed, 0 deleted, 0 unchanged, 1 failed
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ API error_code: INVALID_PARAMETER_VALUE
API message: policy_family_id and definition cannot be used together

Files: 2 uploaded, 0 deleted
Resources: 0 created, 0 changed, 0 deleted, 0 unchanged, 1 failed
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ API error_code: RESOURCE_DOES_NOT_EXIST
API message: Warehouse doesnotexist does not exist

Files: 5 uploaded, 0 deleted
Resources: 0 created, 0 changed, 0 deleted, 0 unchanged, 1 failed

Exit code: 1
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ API error_code: INJECTED
API message: Fault injected by test.

Files: 1 uploaded, 0 deleted
Resources: 0 created, 0 changed, 0 deleted, 0 unchanged, 1 failed

Exit code: 1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ API error_code: INJECTED
API message: Fault injected by test.

Files: 1 uploaded, 0 deleted
Resources: 1 created, 0 changed, 0 deleted, 0 unchanged, 1 failed

Exit code: 1

Expand Down
3 changes: 3 additions & 0 deletions acceptance/bundle/resources/job_runs/failed_run/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ run page: [RUN_URL]
Error: cannot create resources.jobs.downstream_job: dependency failed: resources.job_runs.my_run

Files: 3 uploaded, 0 deleted
Resources: 1 created, 0 changed, 0 deleted, 0 unchanged, 2 failed

=== the failed run is recorded, and not having succeeded is drift

Expand All @@ -27,6 +28,7 @@ Files: 3 uploaded, 0 deleted
}
],
"action": "recreate",
"state_only": true,
"new_state": {
"value": {
"job_id": [MY_JOB_ID],
Expand Down Expand Up @@ -68,6 +70,7 @@ run page: [RUN_URL]
Error: cannot create resources.jobs.downstream_job: dependency failed: resources.job_runs.my_run

Files: 0 uploaded, 0 deleted
Resources: 0 created, 0 changed, 0 deleted, 1 unchanged, 2 failed

=== run-now was issued once per deploy, and the recreate left the failed run alone

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ API error_code: INJECTED
API message: Fault injected by test.

Files: 1 uploaded, 0 deleted
Resources: 1 created, 0 changed, 0 deleted, 0 unchanged, 1 failed

Exit code: 1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Resources: 2 created, 0 changed, 0 deleted, 0 unchanged
>>> [CLI] bundle plan
recreate job_runs.my_run

Plan: 1 to add, 0 to change, 1 to delete, 1 unchanged
Plan: 1 to add, 0 to change, 0 to delete, 1 unchanged

>>> jq .plan["resources.job_runs.my_run"].changes tmp.plan.json
{
Expand All @@ -52,7 +52,7 @@ Output from job_runs.my_run: id=[MY_RUN_ID_2]: Run URL: [DATABRICKS_URL]/jobs/[M
Output from job_runs.my_run: id=[MY_RUN_ID_2]: SUCCESS
Recreated job_runs.my_run
Files: 1 uploaded, 0 deleted
Resources: 1 created, 0 changed, 1 deleted, 1 unchanged
Resources: 1 created, 0 changed, 0 deleted, 1 unchanged

>>> [CLI] bundle summary
Name: job-runs-on-bundle-deploy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Resources: 0 created, 0 changed, 0 deleted, 2 unchanged
}
],
"action": "recreate",
"state_only": true,
"new_state": {
"value": {
"job_id": [MY_JOB_ID],
Expand Down Expand Up @@ -99,7 +100,7 @@ Output from job_runs.my_run: id=[MY_RUN_ID_2]: Run URL: [DATABRICKS_URL]/jobs/[M
Output from job_runs.my_run: id=[MY_RUN_ID_2]: SUCCESS
Recreated job_runs.my_run
Files: 2 uploaded, 0 deleted
Resources: 1 created, 0 changed, 1 deleted, 1 unchanged
Resources: 1 created, 0 changed, 0 deleted, 1 unchanged

>>> print_requests.py --keep //jobs/runs/delete

Expand Down Expand Up @@ -132,6 +133,7 @@ Warning: lifecycle.triggers.on_file_change: no synced files match "seed.txt"
}
],
"action": "recreate",
"state_only": true,
"new_state": {
"value": {
"job_id": [MY_JOB_ID],
Expand Down Expand Up @@ -180,7 +182,7 @@ Output from job_runs.my_run: id=[MY_RUN_ID_3]: Run URL: [DATABRICKS_URL]/jobs/[M
Output from job_runs.my_run: id=[MY_RUN_ID_3]: SUCCESS
Recreated job_runs.my_run
Files: 2 uploaded, 1 deleted
Resources: 1 created, 0 changed, 1 deleted, 1 unchanged
Resources: 1 created, 0 changed, 0 deleted, 1 unchanged

>>> print_requests.py //jobs/run-now
{
Expand All @@ -206,7 +208,7 @@ Output from job_runs.my_run: id=[MY_RUN_ID_4]: Run URL: [DATABRICKS_URL]/jobs/[M
Output from job_runs.my_run: id=[MY_RUN_ID_4]: SUCCESS
Recreated job_runs.my_run
Files: 2 uploaded, 1 deleted
Resources: 1 created, 0 changed, 1 deleted, 1 unchanged
Resources: 1 created, 0 changed, 0 deleted, 1 unchanged

>>> print_requests.py //jobs/run-now
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Output from job_runs.my_run: id=[MY_RUN_ID_2]: Run URL: [DATABRICKS_URL]/jobs/[M
Output from job_runs.my_run: id=[MY_RUN_ID_2]: SUCCESS
Recreated job_runs.my_run
Files: 2 uploaded, 0 deleted
Resources: 1 created, 0 changed, 1 deleted, 1 unchanged
Resources: 1 created, 0 changed, 0 deleted, 1 unchanged

>>> print_requests.py //jobs/run-now
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Output from job_runs.my_run: id=[MY_RUN_ID_2]: Run URL: [DATABRICKS_URL]/jobs/[M
Output from job_runs.my_run: id=[MY_RUN_ID_2]: SUCCESS
Recreated job_runs.my_run
Files: 2 uploaded, 0 deleted
Resources: 1 created, 0 changed, 1 deleted, 1 unchanged
Resources: 1 created, 0 changed, 0 deleted, 1 unchanged

>>> print_requests.py --keep //jobs/runs/delete

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Output from job_runs.my_run: id=[MY_RUN_ID_2]: Run URL: [DATABRICKS_URL]/jobs/[M
Output from job_runs.my_run: id=[MY_RUN_ID_2]: SUCCESS
Recreated job_runs.my_run
Files: 2 uploaded, 0 deleted
Resources: 1 created, 0 changed, 1 deleted, 1 unchanged
Resources: 1 created, 0 changed, 0 deleted, 1 unchanged

>>> print_requests.py //jobs/run-now
{
Expand Down
Loading