Skip to content

Commit 96d017a

Browse files
Suppress /Workspace prefix diff for experiment names in direct deployment (#4627)
## Summary - Use `OverrideChangeDesc` to suppress the `/Workspace` prefix diff on experiment names, matching the Terraform provider's `experimentNameSuppressDiff` behavior - Fix test server `ExperimentUpdate` to strip `/Workspace` prefix, matching cloud behavior - Add acceptance test coverage for both `/Workspace/Users/...` and `/Users/...` path forms - Resolves #4285 #4324 ## Why? The backend always strips the `/Workspace` prefix from experiment names, so remote returns `/Users/...` while the config has `/Workspace/Users/...`. Instead of mutating the config value (stripping the prefix in `ApplyPresets`), we suppress the diff during change detection via `OverrideChangeDesc` — the same approach the Terraform provider uses with its [`experimentNameSuppressDiff`](https://github.com/databricks/terraform-provider-databricks/blob/8945a7b2328659b1fc976d04e32457305860131f/mlflow/resource_mlflow_experiment.go#L13) function. Without this fix you get a persistent drift: ``` "name": { "action": "update", "old": "/Workspace/Users/shreyas.goenka@databricks.com/test-experiment-bundle", "new": "/Workspace/Users/shreyas.goenka@databricks.com/test-experiment-bundle", "remote": "/Users/shreyas.goenka@databricks.com/test-experiment-bundle" }, ``` ## Test plan - [x] Acceptance test `bundle/deployment/bind/experiment` verifies plan shows 0 changes with `/Workspace/Users/...` path - [x] Same test verifies plan shows 0 changes with `/Users/...` path (without `/Workspace` prefix) - [x] `bundle/resources/experiments/basic` acceptance test still passes 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e4d6f25 commit 96d017a

File tree

11 files changed

+115
-22
lines changed

11 files changed

+115
-22
lines changed

acceptance/bundle/deployment/bind/experiment/out.get.direct.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

acceptance/bundle/deployment/bind/experiment/out.get.terraform.json

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"plan": {
3+
"resources.experiments.experiment1": {
4+
"action": "skip",
5+
"name_change": {
6+
"action": "skip",
7+
"reason": "alias",
8+
"old": "/Workspace/Users/[USERNAME]/test-experiment[UNIQUE_NAME]",
9+
"new": "/Workspace/Users/[USERNAME]/test-experiment[UNIQUE_NAME]",
10+
"remote": "/Users/[USERNAME]/test-experiment[UNIQUE_NAME]"
11+
}
12+
}
13+
}
14+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"plan": {
3+
"resources.experiments.experiment1": {
4+
"action": "skip",
5+
"name_change": null
6+
}
7+
}
8+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"plan": {
3+
"resources.experiments.experiment1": {
4+
"action": "skip",
5+
"name_change": {
6+
"action": "skip",
7+
"reason": "remote_already_set",
8+
"old": "/Workspace/Users/[USERNAME]/test-experiment[UNIQUE_NAME]",
9+
"new": "/Users/[USERNAME]/test-experiment[UNIQUE_NAME]",
10+
"remote": "/Users/[USERNAME]/test-experiment[UNIQUE_NAME]"
11+
}
12+
}
13+
}
14+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"plan": {
3+
"resources.experiments.experiment1": {
4+
"action": "skip",
5+
"name_change": null
6+
}
7+
}
8+
}

acceptance/bundle/deployment/bind/experiment/out.test.toml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

acceptance/bundle/deployment/bind/experiment/output.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ Updating deployment state...
1111
Deployment complete!
1212

1313
>>> [CLI] experiments get-experiment [NUMID]
14+
{
15+
"name": "/Users/[USERNAME]/test-experiment[UNIQUE_NAME]",
16+
"lifecycle_stage": "active"
17+
}
1418

1519
>>> [CLI] bundle deployment unbind experiment1
1620
Updating deployment state...
@@ -22,6 +26,10 @@ Deleting files...
2226
Destroy complete!
2327

2428
>>> [CLI] experiments get-experiment [NUMID]
29+
{
30+
"name": "/Users/[USERNAME]/test-experiment[UNIQUE_NAME]",
31+
"lifecycle_stage": "active"
32+
}
2533

2634
=== Test cleanup:
2735
=== Delete the pre-defined experiment: 0

acceptance/bundle/deployment/bind/experiment/script

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,22 @@ trace $CLI bundle deployment bind experiment1 ${EXPERIMENT_ID} --auto-approve
1717

1818
trace $CLI bundle deploy --force-lock --auto-approve
1919

20-
trace $CLI experiments get-experiment ${EXPERIMENT_ID} | jq '{name: .experiment.name, lifecycle_stage: .experiment.lifecycle_stage}' > out.get.$DATABRICKS_BUNDLE_ENGINE.json
20+
# Plan should show no changes with /Workspace/Users/... path in config.
21+
# Use --output json to verify the change details including skip reason.
22+
# Write per-engine output since direct includes change details that terraform doesn't.
23+
# Filter to only the name change (tags/artifact_location may differ between local and cloud).
24+
$CLI bundle plan --output json | jq '{plan: .plan | map_values({action, name_change: (.changes.name // null)})}' > out.plan1.$DATABRICKS_BUNDLE_ENGINE.json
25+
26+
trace $CLI experiments get-experiment ${EXPERIMENT_ID} | jq '{name: .experiment.name, lifecycle_stage: .experiment.lifecycle_stage}'
27+
28+
# Now change the config to use /Users/... path (without /Workspace prefix).
29+
# Plan should still show no changes because the diff is suppressed.
30+
EXPERIMENT_NAME="//Users/${CURRENT_USER_NAME}/test-experiment$UNIQUE_NAME"
31+
envsubst < databricks.yml.tmpl > databricks.yml
32+
$CLI bundle plan --output json | jq '{plan: .plan | map_values({action, name_change: (.changes.name // null)})}' > out.plan2.$DATABRICKS_BUNDLE_ENGINE.json
2133

2234
trace $CLI bundle deployment unbind experiment1
2335

2436
trace $CLI bundle destroy --auto-approve
2537

26-
trace $CLI experiments get-experiment ${EXPERIMENT_ID} | jq '{name: .experiment.name, lifecycle_stage: .experiment.lifecycle_stage}' > out.get2.$DATABRICKS_BUNDLE_ENGINE.json
27-
diff out.get.$DATABRICKS_BUNDLE_ENGINE.json out.get2.$DATABRICKS_BUNDLE_ENGINE.json
28-
rm out.get2.$DATABRICKS_BUNDLE_ENGINE.json
38+
trace $CLI experiments get-experiment ${EXPERIMENT_ID} | jq '{name: .experiment.name, lifecycle_stage: .experiment.lifecycle_stage}'
Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,2 @@
1-
Badness = "Difference in GET request between direct and terraform; In direct, the prefix is /Workspace/Users, in TF it is /Users"
21
Local = true
3-
4-
# Fails on Cloud with:
5-
#=== CONT TestAccept/bundle/deployment/bind/experiment/DATABRICKS_BUNDLE_ENGINE=direct
6-
# - "name": "/Workspace/Users/[USERNAME]/test-experiment[UNIQUE_NAME]",
7-
# + "name": "/Users/[USERNAME]/test-experiment[UNIQUE_NAME]",
8-
# https://github.com/databricks/cli/issues/4285
9-
10-
Cloud = false
2+
Cloud = true

0 commit comments

Comments
 (0)