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/app-source-code-path.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Send `source_code_path` on the app Create request and `git_source` on the app Create and Update requests, so the app records its configured source before its first deployment. ([#6399](https://github.com/databricks/cli/pull/6399))
3 changes: 2 additions & 1 deletion acceptance/bundle/empty_string_dropped/out.requests.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
},
"body": {
"description": "",
"name": "test-app-direct"
"name": "test-app-direct",
"source_code_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/direct/files/app"
}
}
{
Expand Down
3 changes: 2 additions & 1 deletion acceptance/bundle/resource_deps/remote_app_url/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ Resources: 2 created, 0 changed, 0 deleted, 0 unchanged
},
"body": {
"description": "best app",
"name": "myapp"
"name": "myapp",
"source_code_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files/app"
}
}
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ Plan: 0 to add, 0 to change, 0 to delete, 1 unchanged
},
"source_code_path": {
"action": "skip",
"reason": "no active deployment",
"reason": "spec:input_only",
"old": "/Workspace/Users/[USERNAME]/.bundle/app-config-no-deployment/default/files/app",
"new": "/Workspace/Users/[USERNAME]/.bundle/app-config-no-deployment/default/files/app"
"new": "/Workspace/Users/[USERNAME]/.bundle/app-config-no-deployment/default/files/app",
"remote": ""
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Resources: 1 created, 0 changed, 0 deleted, 0 unchanged
},
"body": {
"description": "",
"name": "myappname"
"name": "myappname",
"source_code_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Plan: 0 to add, 0 to change, 0 to delete, 1 unchanged
{
"git_source": {
"action": "skip",
"reason": "no active deployment",
"reason": "spec:input_only",
"old": {
"branch": "main"
},
Expand Down
3 changes: 2 additions & 1 deletion acceptance/bundle/resources/apps/immutable/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ You can access the app at my-immutable-app-123.cloud.databricksapps.com
},
"body": {
"description": "",
"name": "my-immutable-app"
"name": "my-immutable-app",
"source_code_path": "/Workspace/Users/[UUID][0]/.snapshots/[SNAPSHOT_HASH]/[SNAPSHOT_HASH]-[UUID][1]/snapshot/files/app"
}
}
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ Resources: 1 created, 0 changed, 0 deleted, 0 unchanged
},
"body": {
"description": "my_app_description",
"name": "[UNIQUE_NAME]"
"name": "[UNIQUE_NAME]",
"source_code_path": "/Workspace/Users/[USERNAME]/.bundle/lifecycle-started-omitted-[UNIQUE_NAME]/default/files/app"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ Resources: 1 created, 0 changed, 0 deleted, 0 unchanged
},
"body": {
"description": "my_app_description",
"name": "[UNIQUE_NAME]"
"name": "[UNIQUE_NAME]",
"source_code_path": "/Workspace/Users/[USERNAME]/.bundle/lifecycle-started-toggle-[UNIQUE_NAME]/default/files/app"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ Resources: 1 created, 0 changed, 0 deleted, 0 unchanged
"path": "/api/2.0/apps",
"body": {
"description": "my_app_description",
"name": "[UNIQUE_NAME]"
"name": "[UNIQUE_NAME]",
"source_code_path": "/Workspace/Users/[USERNAME]/.bundle/lifecycle-started-[UNIQUE_NAME]/default/files/app"
}
}
{
Expand Down Expand Up @@ -95,7 +96,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_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,git_source,telemetry_export_destinations"
}
}

Expand Down Expand Up @@ -123,7 +124,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_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,git_source,telemetry_export_destinations"
}
}
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ Exit code: 1
},
"body": {
"description": "my_app_description",
"name": "myappname"
"name": "myappname",
"source_code_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files/app"
}
}
{
Expand All @@ -44,7 +45,7 @@ Exit code: 1
"description": "MY_APP_DESCRIPTION",
"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"
"update_mask": "description,budget_policy_id,usage_policy_id,resources,user_api_scopes,compute_min_instances,compute_max_instances,git_repository,git_source,telemetry_export_destinations"
}
}

Expand Down
3 changes: 2 additions & 1 deletion acceptance/bundle/resources/apps/resource-refs/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ You can access the app at data-app-123.cloud.databricksapps.com
},
"body": {
"description": "A Streamlit app that uses a SQL warehouse",
"name": "data-app"
"name": "data-app",
"source_code_path": "/Workspace/Users/[USERNAME]/.bundle/resource-refs/default/files/app"
}
}
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print("v1")
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print("v2")
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
bundle:
name: app-source-code-path-update

resources:
apps:
myapp:
name: test-app-source-code-path-update
description: my_app_description
source_code_path: ./app
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Cloud = false
EnvMatrix.DMS = ["", "true"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@

=== Deploy: source_code_path is sent on Create

>>> [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/app-source-code-path-update/default/files...
Created apps.myapp
Files: 3 uploaded, 0 deleted
Resources: 1 created, 0 changed, 0 deleted, 0 unchanged

>>> print_requests.py //apps
{
"method": "POST",
"path": "/api/2.0/apps",
"q": {
"no_compute": "true"
},
"body": {
"description": "my_app_description",
"name": "test-app-source-code-path-update",
"source_code_path": "/Workspace/Users/[USERNAME]/.bundle/app-source-code-path-update/default/files/app"
}
}

=== Change source_code_path: plan detects an update

>>> update_file.py databricks.yml source_code_path: ./app source_code_path: ./app2

>>> [CLI] bundle plan
update apps.myapp

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

=== Redeploy: UpdateApp rejects source_code_path, so no app request is sent; the next Deploy applies it

>>> [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/app-source-code-path-update/default/files...
Updated apps.myapp
Files: 1 uploaded, 0 deleted
Resources: 0 created, 1 changed, 0 deleted, 0 unchanged

>>> print_requests.py //apps

=== Change description: App Update omits source_code_path from the body and the update mask

>>> update_file.py databricks.yml my_app_description MY_APP_DESCRIPTION

>>> [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/app-source-code-path-update/default/files...
Updated apps.myapp
Files: 1 uploaded, 0 deleted
Resources: 0 created, 1 changed, 0 deleted, 0 unchanged

>>> print_requests.py //apps
{
"method": "POST",
"path": "/api/2.0/apps/test-app-source-code-path-update/update",
"body": {
"app": {
"description": "MY_APP_DESCRIPTION",
"name": "test-app-source-code-path-update"
},
"update_mask": "description,budget_policy_id,usage_policy_id,resources,user_api_scopes,compute_min_instances,compute_max_instances,git_repository,git_source,telemetry_export_destinations"
}
}
16 changes: 16 additions & 0 deletions acceptance/bundle/resources/apps/source-code-path-update/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
title "Deploy: source_code_path is sent on Create"
trace $CLI bundle deploy
trace print_requests.py //apps

title "Change source_code_path: plan detects an update"
trace update_file.py databricks.yml "source_code_path: ./app" "source_code_path: ./app2"
trace $CLI bundle plan

title "Redeploy: UpdateApp rejects source_code_path, so no app request is sent; the next Deploy applies it"
trace $CLI bundle deploy
trace print_requests.py //apps

title "Change description: App Update omits source_code_path from the body and the update mask"
trace update_file.py databricks.yml my_app_description MY_APP_DESCRIPTION
trace $CLI bundle deploy
trace print_requests.py //apps
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Cloud = false

Ignore = [".databricks"]
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"body": {
"compute_size": "LARGE",
"description": "my_app_description",
"name": "myappname"
"name": "myappname",
"source_code_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files/app"
}
}
{
Expand All @@ -19,7 +20,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_size,compute_min_instances,compute_max_instances,git_repository,git_source,telemetry_export_destinations"
}
}
{
Expand All @@ -30,6 +31,6 @@
"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"
"update_mask": "description,budget_policy_id,usage_policy_id,resources,user_api_scopes,compute_min_instances,compute_max_instances,git_repository,git_source,telemetry_export_destinations"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print("v1")
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print("v2")
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
bundle:
name: update-source-code-path-cloud-$UNIQUE_NAME

resources:
apps:
myapp:
name: $UNIQUE_NAME
description: my_app_description
source_code_path: ./app
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Cloud = true
EnvMatrix.DMS = ["", "true"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

=== Deploy: create the app with source_code_path

>>> errcode [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/update-source-code-path-cloud-[UNIQUE_NAME]/default/files...
Created apps.myapp
Files: 4 uploaded, 0 deleted
Resources: 1 created, 0 changed, 0 deleted, 0 unchanged

>>> print_requests.py //apps
{
"method": "POST",
"path": "/api/2.0/apps",
"q": {
"no_compute": "true"
},
"body": {
"description": "my_app_description",
"name": "[UNIQUE_NAME]",
"source_code_path": "/Workspace/Users/[USERNAME]/.bundle/update-source-code-path-cloud-[UNIQUE_NAME]/default/files/app"
}
}

=== Change source_code_path on an existing app: no UpdateApp request is sent

>>> update_file.py databricks.yml source_code_path: ./app source_code_path: ./app2

>>> errcode [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/update-source-code-path-cloud-[UNIQUE_NAME]/default/files...
Updated apps.myapp
Files: 1 uploaded, 0 deleted
Resources: 0 created, 1 changed, 0 deleted, 0 unchanged

>>> print_requests.py //apps

>>> [CLI] bundle destroy --auto-approve
The following resources will be deleted:
delete resources.apps.myapp

All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/update-source-code-path-cloud-[UNIQUE_NAME]/default

Destroy: 1 deleted
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
envsubst < databricks.yml.tmpl > databricks.yml

cleanup() {
trace $CLI bundle destroy --auto-approve
rm -f out.requests.txt
}
trap cleanup EXIT

title "Deploy: create the app with source_code_path"
trace errcode $CLI bundle deploy
trace print_requests.py //apps
rm -f out.requests.txt

title "Change source_code_path on an existing app: no UpdateApp request is sent"
trace update_file.py databricks.yml "source_code_path: ./app" "source_code_path: ./app2"
trace errcode $CLI bundle deploy
trace print_requests.py //apps
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Runs against a real workspace: production rejects source_code_path in the UpdateApp mask
# (400 INVALID_PARAMETER_VALUE), so changing it on an existing app must not call UpdateApp.
# Locally the fake server enforces the same rule; see libs/testserver/apps.go.
Cloud = true
RecordRequests = true

Ignore = [".databricks", "databricks.yml"]

# App deployment progress messages are non-deterministic on cloud (different status messages
# per poll), so filter them out entirely.
[[Repls]]
Old = '(?m)^✓ [^\n]*\n'
New = ""
8 changes: 5 additions & 3 deletions acceptance/bundle/resources/apps/update/out.requests.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
},
"body": {
"description": "my_app_description",
"name": "myappname"
"name": "myappname",
"source_code_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files/app"
}
}
{
Expand All @@ -17,7 +18,7 @@
"description": "MY_APP_DESCRIPTION",
"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"
"update_mask": "description,budget_policy_id,usage_policy_id,resources,user_api_scopes,compute_min_instances,compute_max_instances,git_repository,git_source,telemetry_export_destinations"
}
}
{
Expand All @@ -32,7 +33,8 @@
},
"body": {
"description": "MY_APP_DESCRIPTION",
"name": "mynewappname"
"name": "mynewappname",
"source_code_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files/app"
}
}
{
Expand Down
Loading
Loading