Skip to content

Commit 8ebc0f9

Browse files
authored
direct: Use async Update API for Apps update (#4607)
## Changes Use async Update API for Apps update ## Why Old sync Update API does not support updating compute_size fields ## Tests Added an acceptance test <!-- If your PR needs to be included in the release notes for next release, add a separate entry in NEXT_CHANGELOG.md as part of your PR. -->
1 parent 278e906 commit 8ebc0f9

File tree

17 files changed

+296
-52
lines changed

17 files changed

+296
-52
lines changed

NEXT_CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### CLI
66

77
### Bundles
8+
* direct: Use async Update API for Apps update ([#4607](https://github.com/databricks/cli/pull/4607))
89

910
### Dependency updates
1011

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print("Simple test app")
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
command: ["python", "app.py"]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
bundle:
2+
name: app-git-source-$UNIQUE_NAME
3+
4+
workspace:
5+
root_path: "~/.bundle/app-compute-size-$UNIQUE_NAME"
6+
7+
resources:
8+
apps:
9+
my_app:
10+
name: app-$UNIQUE_NAME
11+
description: "App with compute size"
12+
compute_size: LARGE
13+
source_code_path: ./app

acceptance/bundle/apps/compute_size/out.test.toml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
>>> errcode [CLI] bundle deploy
3+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/app-compute-size-[UNIQUE_NAME]/files...
4+
Deploying resources...
5+
Updating deployment state...
6+
Deployment complete!
7+
8+
>>> [CLI] apps get app-[UNIQUE_NAME]
9+
{
10+
"compute_size": "MEDIUM"
11+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
>>> errcode [CLI] bundle deploy
3+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/app-compute-size-[UNIQUE_NAME]/files...
4+
Deploying resources...
5+
Error: terraform apply: exit status 1
6+
7+
Error: failed to update app
8+
9+
with databricks_app.my_app,
10+
on bundle.tf.json line 20, in resource.databricks_app.my_app:
11+
20: }
12+
13+
Compute size updates are not supported in this update API. Please use the new
14+
update API instead.
15+
16+
17+
Updating deployment state...
18+
19+
Exit code: 1
20+
21+
>>> [CLI] apps get app-[UNIQUE_NAME]
22+
{
23+
"compute_size": "LARGE"
24+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
=== Deploy bundle
3+
>>> [CLI] bundle deploy
4+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/app-compute-size-[UNIQUE_NAME]/files...
5+
Deploying resources...
6+
Updating deployment state...
7+
Deployment complete!
8+
9+
=== Update compute size and redeploy
10+
>>> [CLI] bundle destroy --auto-approve
11+
The following resources will be deleted:
12+
delete resources.apps.my_app
13+
14+
All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/app-compute-size-[UNIQUE_NAME]
15+
16+
Deleting files...
17+
Destroy complete!
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
# Generate databricks.yml from template
4+
envsubst < databricks.yml.tmpl > databricks.yml
5+
6+
# Set up cleanup trap to ensure resources are destroyed even on failure
7+
cleanup() {
8+
trace $CLI bundle destroy --auto-approve
9+
}
10+
trap cleanup EXIT
11+
12+
title "Deploy bundle"
13+
trace $CLI bundle deploy
14+
15+
title "Update compute size and redeploy"
16+
sed -i.bak 's/compute_size: LARGE/compute_size: MEDIUM/' databricks.yml
17+
{
18+
trace errcode $CLI bundle deploy
19+
trace $CLI apps get "app-$UNIQUE_NAME" | jq '{compute_size: .compute_size}'
20+
} &> out.update.$DATABRICKS_BUNDLE_ENGINE.txt
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Local = true
2+
Cloud = true
3+
RecordRequests = false
4+
5+
Ignore = [".databricks", "databricks.yml", "databricks.yml.bak", "out.app-run"]
6+
7+
# Apps can take longer to deploy
8+
TimeoutCloud = "5m"
9+
10+
# Simulate the Terraform provider's old update API not supporting compute_size changes.
11+
[[Server]]
12+
Pattern = "PATCH /api/2.0/apps/{name}"
13+
Response.StatusCode = 400
14+
Response.Body = '{"error_code": "INVALID_PARAMETER_VALUE", "message": "Compute size updates are not supported in this update API. Please use the new update API instead."}'

0 commit comments

Comments
 (0)