From bb408c19d37ef567bd6f3de974d2e7aee0ec91a7 Mon Sep 17 00:00:00 2001 From: Andrew Nester Date: Wed, 11 Nov 2026 13:11:14 +0100 Subject: [PATCH 1/2] Leave compute_size out of app update mask when not declared The app update mask always named compute_size, but the request body omits it when the bundle does not declare it. The backend applies the named field, so a deploy silently reset a manually resized app to the default size. Build the mask per request and drop compute_size when the body does not carry it. Co-authored-by: Isaac --- .../bundles/app-update-mask-compute-size.md | 1 + .../apps/lifecycle-started/output.txt | 4 +-- .../apps/update-compute-size/app/app.py | 1 + .../apps/update-compute-size/databricks.yml | 10 ++++++ .../update-compute-size/out.requests.json | 35 ++++++++++++++++++ .../apps/update-compute-size/out.test.toml | 2 ++ .../apps/update-compute-size/output.txt | 36 +++++++++++++++++++ .../resources/apps/update-compute-size/script | 21 +++++++++++ .../resources/apps/update/out.requests.json | 2 +- bundle/direct/dresources/app.go | 16 +++++++-- bundle/direct/dresources/app_test.go | 19 ++++++++++ 11 files changed, 142 insertions(+), 5 deletions(-) create mode 100644 .nextchanges/bundles/app-update-mask-compute-size.md create mode 100644 acceptance/bundle/resources/apps/update-compute-size/app/app.py create mode 100644 acceptance/bundle/resources/apps/update-compute-size/databricks.yml create mode 100644 acceptance/bundle/resources/apps/update-compute-size/out.requests.json create mode 100644 acceptance/bundle/resources/apps/update-compute-size/out.test.toml create mode 100644 acceptance/bundle/resources/apps/update-compute-size/output.txt create mode 100644 acceptance/bundle/resources/apps/update-compute-size/script diff --git a/.nextchanges/bundles/app-update-mask-compute-size.md b/.nextchanges/bundles/app-update-mask-compute-size.md new file mode 100644 index 00000000000..fab6fb13c5d --- /dev/null +++ b/.nextchanges/bundles/app-update-mask-compute-size.md @@ -0,0 +1 @@ +* Stop sending `compute_size` in the app update mask when the bundle does not declare it, so a deploy no longer resets a manually resized app to the default size. diff --git a/acceptance/bundle/resources/apps/lifecycle-started/output.txt b/acceptance/bundle/resources/apps/lifecycle-started/output.txt index 05c88f1cd78..becd0f95b05 100644 --- a/acceptance/bundle/resources/apps/lifecycle-started/output.txt +++ b/acceptance/bundle/resources/apps/lifecycle-started/output.txt @@ -90,7 +90,7 @@ Resources: 0 created, 1 changed, 0 deleted, 0 unchanged "description": "MY_APP_DESCRIPTION_2", "name": "[UNIQUE_NAME]" }, - "update_mask": "description,budget_policy_id,usage_policy_id,resources,user_api_scopes,compute_size,compute_min_instances,compute_max_instances,git_repository,telemetry_export_destinations" + "update_mask": "description,budget_policy_id,usage_policy_id,resources,user_api_scopes,compute_min_instances,compute_max_instances,git_repository,telemetry_export_destinations" } } @@ -117,7 +117,7 @@ Resources: 0 created, 1 changed, 0 deleted, 0 unchanged "description": "MY_APP_DESCRIPTION_3", "name": "[UNIQUE_NAME]" }, - "update_mask": "description,budget_policy_id,usage_policy_id,resources,user_api_scopes,compute_size,compute_min_instances,compute_max_instances,git_repository,telemetry_export_destinations" + "update_mask": "description,budget_policy_id,usage_policy_id,resources,user_api_scopes,compute_min_instances,compute_max_instances,git_repository,telemetry_export_destinations" } } { diff --git a/acceptance/bundle/resources/apps/update-compute-size/app/app.py b/acceptance/bundle/resources/apps/update-compute-size/app/app.py new file mode 100644 index 00000000000..f1a18139c84 --- /dev/null +++ b/acceptance/bundle/resources/apps/update-compute-size/app/app.py @@ -0,0 +1 @@ +print("Hello world!") diff --git a/acceptance/bundle/resources/apps/update-compute-size/databricks.yml b/acceptance/bundle/resources/apps/update-compute-size/databricks.yml new file mode 100644 index 00000000000..491ccf46204 --- /dev/null +++ b/acceptance/bundle/resources/apps/update-compute-size/databricks.yml @@ -0,0 +1,10 @@ +bundle: + name: test-bundle + +resources: + apps: + mykey: + name: myappname + description: my_app_description + compute_size: LARGE + source_code_path: ./app diff --git a/acceptance/bundle/resources/apps/update-compute-size/out.requests.json b/acceptance/bundle/resources/apps/update-compute-size/out.requests.json new file mode 100644 index 00000000000..c39f33c9920 --- /dev/null +++ b/acceptance/bundle/resources/apps/update-compute-size/out.requests.json @@ -0,0 +1,35 @@ +{ + "method": "POST", + "path": "/api/2.0/apps", + "q": { + "no_compute": "true" + }, + "body": { + "compute_size": "LARGE", + "description": "my_app_description", + "name": "myappname" + } +} +{ + "method": "POST", + "path": "/api/2.0/apps/myappname/update", + "body": { + "app": { + "compute_size": "LARGE", + "description": "MY_APP_DESCRIPTION", + "name": "myappname" + }, + "update_mask": "description,budget_policy_id,usage_policy_id,resources,user_api_scopes,compute_size,compute_min_instances,compute_max_instances,git_repository,telemetry_export_destinations" + } +} +{ + "method": "POST", + "path": "/api/2.0/apps/myappname/update", + "body": { + "app": { + "description": "MY_APP_DESCRIPTION_2", + "name": "myappname" + }, + "update_mask": "description,budget_policy_id,usage_policy_id,resources,user_api_scopes,compute_min_instances,compute_max_instances,git_repository,telemetry_export_destinations" + } +} diff --git a/acceptance/bundle/resources/apps/update-compute-size/out.test.toml b/acceptance/bundle/resources/apps/update-compute-size/out.test.toml new file mode 100644 index 00000000000..a927a5fbc06 --- /dev/null +++ b/acceptance/bundle/resources/apps/update-compute-size/out.test.toml @@ -0,0 +1,2 @@ +Cloud = false +EnvMatrix.DMS = ["", "true"] diff --git a/acceptance/bundle/resources/apps/update-compute-size/output.txt b/acceptance/bundle/resources/apps/update-compute-size/output.txt new file mode 100644 index 00000000000..be44bf5f2e7 --- /dev/null +++ b/acceptance/bundle/resources/apps/update-compute-size/output.txt @@ -0,0 +1,36 @@ + +=== Deploy with compute_size declared +>>> [CLI] bundle deploy +Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files... +Created apps.mykey +Files: 2 uploaded, 0 deleted +Resources: 1 created, 0 changed, 0 deleted, 0 unchanged + +>>> print_requests + +=== Update description while compute_size is still declared +>>> update_file.py databricks.yml my_app_description MY_APP_DESCRIPTION + +>>> [CLI] bundle deploy +Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files... +Updated apps.mykey +Files: 2 uploaded, 0 deleted +Resources: 0 created, 1 changed, 0 deleted, 0 unchanged + +>>> print_requests + +=== Remove compute_size and update description +>>> update_file.py databricks.yml MY_APP_DESCRIPTION MY_APP_DESCRIPTION_2 + +>>> [CLI] bundle plan +update apps.mykey + +Plan: 0 to add, 1 to change, 0 to delete, 0 unchanged + +>>> [CLI] bundle deploy +Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files... +Updated apps.mykey +Files: 2 uploaded, 0 deleted +Resources: 0 created, 1 changed, 0 deleted, 0 unchanged + +>>> print_requests diff --git a/acceptance/bundle/resources/apps/update-compute-size/script b/acceptance/bundle/resources/apps/update-compute-size/script new file mode 100644 index 00000000000..8c50d23a121 --- /dev/null +++ b/acceptance/bundle/resources/apps/update-compute-size/script @@ -0,0 +1,21 @@ +print_requests() { + # url is output-only field that terraform adds but that is ignored by the backend + print_requests.py //apps '^//api/2.0/bundle' --del-body url +} + +title "Deploy with compute_size declared" +trace $CLI bundle deploy +trace print_requests > out.requests.json + +title "Update description while compute_size is still declared" +trace update_file.py databricks.yml my_app_description MY_APP_DESCRIPTION +trace $CLI bundle deploy +trace print_requests >> out.requests.json + +title "Remove compute_size and update description" +grep -v compute_size databricks.yml > databricks.yml.new +mv databricks.yml.new databricks.yml +trace update_file.py databricks.yml MY_APP_DESCRIPTION MY_APP_DESCRIPTION_2 +trace $CLI bundle plan +trace $CLI bundle deploy +trace print_requests >> out.requests.json diff --git a/acceptance/bundle/resources/apps/update/out.requests.json b/acceptance/bundle/resources/apps/update/out.requests.json index e68269ec514..0d5a3bb4f1e 100644 --- a/acceptance/bundle/resources/apps/update/out.requests.json +++ b/acceptance/bundle/resources/apps/update/out.requests.json @@ -17,7 +17,7 @@ "description": "MY_APP_DESCRIPTION", "name": "myappname" }, - "update_mask": "description,budget_policy_id,usage_policy_id,resources,user_api_scopes,compute_size,compute_min_instances,compute_max_instances,git_repository,telemetry_export_destinations" + "update_mask": "description,budget_policy_id,usage_policy_id,resources,user_api_scopes,compute_min_instances,compute_max_instances,git_repository,telemetry_export_destinations" } } { diff --git a/bundle/direct/dresources/app.go b/bundle/direct/dresources/app.go index 22cd7cc2b4e..841371d323b 100644 --- a/bundle/direct/dresources/app.go +++ b/bundle/direct/dresources/app.go @@ -176,7 +176,19 @@ var UpdateMaskFields = []string{ "telemetry_export_destinations", } -var updateMask = strings.Join(UpdateMaskFields, ",") +// appUpdateMask returns the update mask for an app update request. compute_size is a +// backend default (see configs/apps.yml), so when the bundle does not declare it the field +// is left out of the mask. Naming it while the body omits it asks the backend to reset the +// size to its default on every deploy, even when the app was resized out of band. +func appUpdateMask(app *apps.App) string { + fields := UpdateMaskFields + if app.ComputeSize == "" { + fields = slices.DeleteFunc(slices.Clone(UpdateMaskFields), func(f string) bool { + return f == "compute_size" + }) + } + return strings.Join(fields, ",") +} func (r *ResourceApp) DoUpdate(ctx context.Context, id string, config *AppState, entry *PlanEntry) (*AppRemote, error) { // Deploy-only fields (source_code_path, config, git_source, lifecycle) are excluded @@ -186,7 +198,7 @@ func (r *ResourceApp) DoUpdate(ctx context.Context, id string, config *AppState, request := apps.AsyncUpdateAppRequest{ App: &app, AppName: id, - UpdateMask: updateMask, + UpdateMask: appUpdateMask(&app), } updateWaiter, err := r.client.Apps.CreateUpdate(ctx, request) if err != nil { diff --git a/bundle/direct/dresources/app_test.go b/bundle/direct/dresources/app_test.go index a32dbdeb0ed..1e064a95a20 100644 --- a/bundle/direct/dresources/app_test.go +++ b/bundle/direct/dresources/app_test.go @@ -173,6 +173,25 @@ func TestAppDoUpdate_UpdateMaskHasAllFields(t *testing.T) { } } +func TestAppUpdateMask_ComputeSizeFollowsBody(t *testing.T) { + tests := []struct { + name string + computeSize apps.ComputeSize + wantCompute bool + }{ + {name: "declared", computeSize: apps.ComputeSizeLarge, wantCompute: true}, + {name: "undeclared", computeSize: "", wantCompute: false}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + mask := strings.Split(appUpdateMask(&apps.App{ComputeSize: tt.computeSize}), ",") + assert.Equal(t, tt.wantCompute, slices.Contains(mask, "compute_size")) + assert.Contains(t, mask, "description") + assert.Contains(t, mask, "compute_min_instances") + }) + } +} + // TestAppRequestBody_StripsSourceCodePathFromForceSendFields verifies that // appRequestBody removes SourceCodePath from ForceSendFields even when the plan // JSON round-trip has forced it in — reproduces the v1.14.0 regression where From bc44628c583176afa53378bdffb3f5cec981f96f Mon Sep 17 00:00:00 2001 From: Andrew Nester Date: Wed, 11 Nov 2026 13:11:27 +0100 Subject: [PATCH 2/2] Link changelog entry to PR #7461 Co-authored-by: Isaac --- .nextchanges/bundles/app-update-mask-compute-size.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.nextchanges/bundles/app-update-mask-compute-size.md b/.nextchanges/bundles/app-update-mask-compute-size.md index fab6fb13c5d..e8af8bd5b48 100644 --- a/.nextchanges/bundles/app-update-mask-compute-size.md +++ b/.nextchanges/bundles/app-update-mask-compute-size.md @@ -1 +1 @@ -* Stop sending `compute_size` in the app update mask when the bundle does not declare it, so a deploy no longer resets a manually resized app to the default size. +* Stop sending `compute_size` in the app update mask when the bundle does not declare it, so a deploy no longer resets a manually resized app to the default size. ([#7461](https://github.com/databricks/cli/pull/7461))