Skip to content

Commit f0e65f7

Browse files
committed
direct: save state before publishing dashboard; add acceptance tests
dashboard.DoCreate now calls engine.SaveState immediately after the dashboard is created (with etag persisted), before publishDashboard. A failed publish leaves the draft tracked in state rather than orphaned; the next deploy finds it via DoRead and re-publishes via DoUpdate without recreating the dashboard. The old trash-on-publish-failure cleanup is removed — it was a fragile workaround for the lack of state persistence and is now unnecessary. Acceptance tests: - publish-failure-cleans-up-dashboard: updated to reflect the new behavior per engine (direct: draft persists with URL; terraform: existing behavior, cleaned up). Output files split to per-engine variants (out.summary.*.txt, out.dashboardrequests.*.txt). - publish-failure-retry (new, direct only): verifies end-to-end that a transient publish failure leaves the draft in state (summary shows URL, plan detects diff), and the subsequent deploy re-publishes without issuing a CREATE call. Co-authored-by: Denis Bilenko
1 parent 3923d84 commit f0e65f7

14 files changed

Lines changed: 191 additions & 26 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"method": "POST",
3+
"path": "/api/2.0/workspace/mkdirs",
4+
"body": {
5+
"path": "/Workspace/Users/[USERNAME]/.bundle/publish-failure-cleans-up-dashboard/default/artifacts/.internal"
6+
}
7+
}
8+
{
9+
"method": "POST",
10+
"path": "/api/2.0/workspace/mkdirs",
11+
"body": {
12+
"path": "/Workspace/Users/[USERNAME]/.bundle/publish-failure-cleans-up-dashboard/default/files"
13+
}
14+
}
15+
{
16+
"method": "POST",
17+
"path": "/api/2.0/workspace/mkdirs",
18+
"body": {
19+
"path": "/Workspace/Users/[USERNAME]/.bundle/publish-failure-cleans-up-dashboard/default/resources"
20+
}
21+
}
22+
{
23+
"method": "POST",
24+
"path": "/api/2.0/lakeview/dashboards",
25+
"body": {
26+
"display_name": "my dashboard",
27+
"parent_path": "/Workspace/Users/[USERNAME]/.bundle/publish-failure-cleans-up-dashboard/default/resources",
28+
"serialized_dashboard": "{\"pages\":[{\"name\":\"test-page\",\"displayName\":\"Test Dashboard\"}]}\n",
29+
"warehouse_id": "doesnotexist"
30+
}
31+
}
32+
{
33+
"method": "POST",
34+
"path": "/api/2.0/lakeview/dashboards/[DASHBOARD_ID]/published",
35+
"body": {
36+
"embed_credentials": false,
37+
"warehouse_id": "doesnotexist"
38+
}
39+
}

acceptance/bundle/resources/dashboards/publish-failure-cleans-up-dashboard/out.dashboardrequests.txt renamed to acceptance/bundle/resources/dashboards/publish-failure-cleans-up-dashboard/out.dashboardrequests.terraform.txt

File renamed without changes.

acceptance/bundle/resources/dashboards/publish-failure-cleans-up-dashboard/out.deploy.direct.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ HTTP Status: 400 Bad Request
99
API error_code: RESOURCE_DOES_NOT_EXIST
1010
API message: Warehouse doesnotexist does not exist
1111

12+
Updating deployment state...
1213

1314
Exit code: 1
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
>>> [CLI] bundle summary
3+
Name: publish-failure-cleans-up-dashboard
4+
Target: default
5+
Workspace:
6+
User: [USERNAME]
7+
Path: /Workspace/Users/[USERNAME]/.bundle/publish-failure-cleans-up-dashboard/default
8+
Resources:
9+
Dashboards:
10+
dashboard1:
11+
Name: my dashboard
12+
URL: [DATABRICKS_URL]/dashboardsv3/[DASHBOARD_ID]/published?o=[NUMID]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
>>> [CLI] bundle summary
3+
Name: publish-failure-cleans-up-dashboard
4+
Target: default
5+
Workspace:
6+
User: [USERNAME]
7+
Path: /Workspace/Users/[USERNAME]/.bundle/publish-failure-cleans-up-dashboard/default
8+
Resources:
9+
Dashboards:
10+
dashboard1:
11+
Name: my dashboard
12+
URL: (not deployed)
Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +0,0 @@
1-
2-
>>> [CLI] bundle summary
3-
Name: publish-failure-cleans-up-dashboard
4-
Target: default
5-
Workspace:
6-
User: [USERNAME]
7-
Path: /Workspace/Users/[USERNAME]/.bundle/publish-failure-cleans-up-dashboard/default
8-
Resources:
9-
Dashboards:
10-
dashboard1:
11-
Name: my dashboard
12-
URL: (not deployed)

acceptance/bundle/resources/dashboards/publish-failure-cleans-up-dashboard/script

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ envsubst < databricks.yml.tmpl > databricks.yml
44
# Deploy the dashboard. The dashboard will be created but publish will fail because the warehouse does not exist.
55
errcode trace $CLI bundle deploy &> out.deploy.$DATABRICKS_BUNDLE_ENGINE.txt
66

7-
trace $CLI bundle summary
7+
# After publish failure the dashboard draft should be in state (direct) or cleaned up (terraform).
8+
trace $CLI bundle summary &>> out.summary.$DATABRICKS_BUNDLE_ENGINE.txt
89

9-
# API should record a DELETE call to clean up the draft dashboard that was not published.
10-
# Request sequence is identical across terraform and direct modes.
10+
# API request sequence differs between engines (direct: no DELETE; terraform: DELETE to clean up).
1111
unset MSYS_NO_PATHCONV
12-
print_requests.py //lakeview/dashboards //workspace/mkdirs > out.dashboardrequests.txt
12+
print_requests.py //lakeview/dashboards //workspace/mkdirs > out.dashboardrequests.$DATABRICKS_BUNDLE_ENGINE.txt
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"pages":[{"name":"test-page","displayName":"Test Dashboard"}]}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
bundle:
2+
name: publish-failure-retry
3+
4+
resources:
5+
dashboards:
6+
dashboard1:
7+
display_name: my dashboard
8+
warehouse_id: someid
9+
file_path: ./dashboard.lvdash.json

acceptance/bundle/resources/dashboards/publish-failure-retry/out.test.toml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)