Repository navigation
Conversation
`resources.apps.<key>.thumbnail_path` points at a local PNG or JPEG image that `bundle deploy` uploads as the app's thumbnail in the Apps UI. The Apps API can't return the image, so the direct engine keeps only a hash of it in state (hashed_fields): an unchanged file makes no API call, new content uploads only the thumbnail (no app update), and removing the field deletes the thumbnail. The file is checked when the bundle is loaded, so `bundle validate` already rejects files that aren't PNG or JPEG (by signature, like the API) or are larger than 250,000 bytes, the limit of the Apps UI and of the Terraform provider's databricks_app.thumbnail_path. Co-authored-by: Isaac <no-reply@databricks.com>
bb827e0 to
8eac7c0
Compare
|
Commit: Regression test reportSelected 4 changed tests (limit=20, 0 not selected) 8 tests: regression=8 unreleased=0 coverage=0 failing=0
TestAccept/bundle/refschema/DMS=: branch ✅ | main (f4a7fe5) ❌ | latest (v1.27.0) ❌main (f4a7fe5): latest (v1.27.0): same output as main (f4a7fe5) TestAccept/bundle/refschema/DMS=true: branch ✅ | main (f4a7fe5) ❌ | latest (v1.27.0) ❌main (f4a7fe5): latest (v1.27.0): same output as main (f4a7fe5) TestAccept/bundle/resources/apps/thumbnail-invalid/DMS=: branch ✅ | main (f4a7fe5) ❌ | latest (v1.27.0) ❌main (f4a7fe5): latest (v1.27.0): same output as main (f4a7fe5) TestAccept/bundle/resources/apps/thumbnail-invalid/DMS=true: branch ✅ | main (f4a7fe5) ❌ | latest (v1.27.0) ❌main (f4a7fe5): latest (v1.27.0): same output as main (f4a7fe5) TestAccept/bundle/resources/apps/thumbnail-upload-fails/DMS=: branch ✅ | main (f4a7fe5) ❌ | latest (v1.27.0) ❌main (f4a7fe5): latest (v1.27.0): same output as main (f4a7fe5) TestAccept/bundle/resources/apps/thumbnail-upload-fails/DMS=true: branch ✅ | main (f4a7fe5) ❌ | latest (v1.27.0) ❌main (f4a7fe5): latest (v1.27.0): same output as main (f4a7fe5) TestAccept/bundle/resources/apps/thumbnail/DMS=: branch ✅ | main (f4a7fe5) ❌ | latest (v1.27.0) ❌main (f4a7fe5): latest (v1.27.0): same output as main (f4a7fe5) TestAccept/bundle/resources/apps/thumbnail/DMS=true: branch ✅ | main (f4a7fe5) ❌ | latest (v1.27.0) ❌main (f4a7fe5): latest (v1.27.0): same output as main (f4a7fe5) |
✅ Integration test reportCommit: 45e5e50
Top 3 slowest tests (at least 2 minutes):
|
Co-authored-by: Isaac <no-reply@databricks.com>
|
/review |
|
|
||
| // AppsGet returns the app, keeping DELETING resources visible so callers can | ||
| // observe transient state (matches the cloud DELETE lifecycle). | ||
| // AppsUpdateThumbnail sets thumbnail_url, the only trace of the image the real API returns. |
There was a problem hiding this comment.
The two new functions were inserted between the AppsGet doc comment (lines 227–228) and AppsGet itself (now line 256). Go treats consecutive // lines as a single block, so AppsUpdateThumbnail now carries AppsGet's comment and AppsGet has none. Move the AppsGet comment down to just above func (s *FakeWorkspace) AppsGet.
There was a problem hiding this comment.
Done — AppsGet's comment moved back down to AppsGet, and AppsDeleteThumbnail got its own.
| // and the next deploy retries it. Failing here would leave the new app out of the state. | ||
| if config.Thumbnail != "" { | ||
| if err := r.updateThumbnail(ctx, app.Name, config.Thumbnail); err != nil { | ||
| cmdio.LogString(ctx, fmt.Sprintf("Warning: failed to upload the thumbnail of app %s, the next deploy retries it: %s", app.Name, err)) |
There was a problem hiding this comment.
can we use diags here for warning?
There was a problem hiding this comment.
The direct apply path has no diag plumbing: adapters and the apply loop return only errors, so a diag.Warning can't travel out of DoCreate. The loop surfaces progress via cmdio.LogString (the Updated apps.mykey lines), so the warning uses the same channel and is visible at the default log level; log.Warnf would only show with --log-level raised.
| trace print_requests.py //apps '^//api/2.0/bundle' | jq -r '.body.app_thumbnail.thumbnail | .[0:12]' | ||
|
|
||
| title "Remove thumbnail_path: the thumbnail is deleted" | ||
| grep -v thumbnail_path databricks.yml > databricks.yml.new |
There was a problem hiding this comment.
there's a python helper to update databricks.yml in-place
There was a problem hiding this comment.
Done — now update_file.py databricks.yml $' thumbnail_path: ./thumbnail.png\n' '' (untraced, like the dms tests).
| trap cleanup EXIT | ||
|
|
||
| title "A failed upload after create keeps the app in state and leaves the thumbnail out of it" | ||
| trace $CLI bundle deploy |
There was a problem hiding this comment.
Kept errcode here deliberately: this deploy should exit 0. The app was already created, so failing the deploy would leave it out of the bundle state and the next deploy would try to create it again (name conflict). The warning keeps the app managed with the thumbnail left out of state, so the next deploy retries it — that retry is the musterr in the next section.
|
|
||
| title "The next deploy retries the upload" | ||
| trace $CLI bundle plan | ||
| errcode trace $CLI bundle deploy |
| title "thumbnail_path: $THUMBNAIL_PATH" | ||
| export THUMBNAIL_PATH | ||
| envsubst < databricks.yml.tmpl > databricks.yml | ||
| errcode trace $CLI bundle validate |
| @@ -0,0 +1,2 @@ | |||
| Cloud = false | |||
There was a problem hiding this comment.
why not Cloud = true to encode server limit on image size and type being rejected
There was a problem hiding this comment.
ditto for other sibling tests
There was a problem hiding this comment.
Added Cloud = true. One caveat: these checks fire at bundle load, before any API call, so the cloud run exercises the same client-side rejection against a real workspace, not the server's own limit (the API accepts PNG/JPEG and larger payloads; 250 KB matches the Apps UI and the Terraform provider).
There was a problem hiding this comment.
The other two are fake-server-only: thumbnail records requests with print_requests and thumbnail-upload-fails injects a 400 via a [[Server]] override, so they can't run in the cloud matrix. The real-workspace behavior (set / unchanged no-op / change / remove / JPEG / GIF rejected) was verified by hand against a staging workspace — see the PR description.
Co-authored-by: Isaac <no-reply@databricks.com>
# Conflicts: # bundle/direct/dresources/app.go
Co-authored-by: Isaac <no-reply@databricks.com>
Changes
New
resources.apps.<key>.thumbnail_path: path of a local PNG or JPEG image, relative to the file that defines the app.bundle deployuploads it as the app's thumbnail in the Apps UI (PATCH /api/2.0/apps/{name}/thumbnail).thumbnail_url, so the direct engine keeps a hash of it in state (hashed_fields, as fordashboards.serialized_dashboard). An unchanged file makes no API call. New content uploads only the thumbnail, without an app update. Removing the field deletes the thumbnail (DELETE .../thumbnail). A bundle that never sets the field leaves a thumbnail uploaded in the UI alone.bundle validaterejects a missing file, a file that isn't PNG or JPEG (detected by its signature, as the API does), or one over 250,000 bytes.Why
Apps can have a thumbnail, but bundles had no way to set it.
thumbnail_pathfollows the_pathnaming of other local-file fields (source_code_path,file_path). It is also the name of the matchingdatabricks_appargument in Add thumbnail_path to databricks_app terraform-provider-databricks#6196.Tests
bundle/resources/apps/thumbnailrecords the requests for: create plus upload, an unchanged redeploy (no thumbnail request), new content (thumbnail upload only),deploy --planfrom a saved plan (uploads the image, not its hash), removal (delete), and destroy.thumbnail-invalidcoversbundle validateerrors.thumbnail-upload-failscovers the warn-and-retry path on create../task fmt,./task checksand./task lint,go test ./bundle/... ./libs/testserver/...and the full local acceptance suite.thumbnail_url.GET /apps/{name}.PATCH .../thumbnail.bundle validate.DELETE .../thumbnail.This pull request and its description were written by Isaac.