diff --git a/NEXT_CHANGELOG.md b/NEXT_CHANGELOG.md index ede82f77791..6268f2492ba 100644 --- a/NEXT_CHANGELOG.md +++ b/NEXT_CHANGELOG.md @@ -12,6 +12,7 @@ ### Bundles * Remove `experimental-jobs-as-code` template, superseded by `pydabs` ([#4999](https://github.com/databricks/cli/pull/4999)). * engine/direct: Added support for Vector Search Endpoints ([#4887](https://github.com/databricks/cli/pull/4887)) +* engine/direct: Exclude deploy-only fields (e.g. `lifecycle`) from the Apps update mask so requests that change both `description` and `lifecycle.started` in the same deploy no longer fail with `INVALID_PARAMETER_VALUE`. ### Dependency updates diff --git a/acceptance/bundle/resources/apps/lifecycle-started/output.txt b/acceptance/bundle/resources/apps/lifecycle-started/output.txt index f5cfeeb0214..b07d44dc5ac 100644 --- a/acceptance/bundle/resources/apps/lifecycle-started/output.txt +++ b/acceptance/bundle/resources/apps/lifecycle-started/output.txt @@ -70,7 +70,23 @@ Deploying resources... Updating deployment state... Deployment complete! ->>> print_requests.py //deployments +>>> print_requests.py //apps +{ + "method": "POST", + "path": "/api/2.0/apps/[UNIQUE_NAME]/stop", + "body": {} +} +{ + "method": "POST", + "path": "/api/2.0/apps/[UNIQUE_NAME]/update", + "body": { + "app": { + "description": "MY_APP_DESCRIPTION_2", + "name": "[UNIQUE_NAME]" + }, + "update_mask": "description" + } +} >>> errcode [CLI] apps get [UNIQUE_NAME] "STOPPED" @@ -87,7 +103,23 @@ Deploying resources... Updating deployment state... Deployment complete! ->>> print_requests.py //deployments +>>> print_requests.py //apps +{ + "method": "POST", + "path": "/api/2.0/apps/[UNIQUE_NAME]/update", + "body": { + "app": { + "description": "MY_APP_DESCRIPTION_3", + "name": "[UNIQUE_NAME]" + }, + "update_mask": "description" + } +} +{ + "method": "POST", + "path": "/api/2.0/apps/[UNIQUE_NAME]/start", + "body": {} +} { "method": "POST", "path": "/api/2.0/apps/[UNIQUE_NAME]/deployments", diff --git a/acceptance/bundle/resources/apps/lifecycle-started/script b/acceptance/bundle/resources/apps/lifecycle-started/script index f356cea4b3d..710dec5a10a 100644 --- a/acceptance/bundle/resources/apps/lifecycle-started/script +++ b/acceptance/bundle/resources/apps/lifecycle-started/script @@ -31,7 +31,7 @@ title "Stop app externally, then deploy with started=false: app stays stopped" trace update_file.py databricks.yml "started: true" "started: false" trace update_file.py databricks.yml MY_APP_DESCRIPTION MY_APP_DESCRIPTION_2 trace errcode $CLI bundle deploy -trace print_requests.py //deployments +trace print_requests.py //apps rm -f out.requests.txt { trace errcode $CLI apps get $UNIQUE_NAME | jq '.compute_status.state'; } || true @@ -39,6 +39,6 @@ title "Deploy with started=true: compute restarted and code deployed" trace update_file.py databricks.yml "started: false" "started: true" trace update_file.py databricks.yml MY_APP_DESCRIPTION_2 MY_APP_DESCRIPTION_3 trace errcode $CLI bundle deploy -trace print_requests.py //deployments +trace print_requests.py //apps rm -f out.requests.txt { trace errcode $CLI apps get $UNIQUE_NAME | jq '.compute_status.state'; } || true diff --git a/bundle/direct/dresources/app.go b/bundle/direct/dresources/app.go index 45eae12fe3f..b40a22b9412 100644 --- a/bundle/direct/dresources/app.go +++ b/bundle/direct/dresources/app.go @@ -172,6 +172,9 @@ func (r *ResourceApp) DoUpdate(ctx context.Context, id string, config *AppState, for i, fieldPath := range fieldPaths { fieldPaths[i] = truncateAtIndex(fieldPath) } + fieldPaths = slices.DeleteFunc(fieldPaths, func(p string) bool { + return deployOnlyFields[p] + }) updateMask := strings.Join(fieldPaths, ",") request := apps.AsyncUpdateAppRequest{ App: &config.App,