From 64abafde7c4e1c6599e88635addb46fd462a4430 Mon Sep 17 00:00:00 2001 From: "ilya.kuznetsov" Date: Tue, 24 Nov 2026 19:58:46 +0000 Subject: [PATCH 1/8] WIP: implement --- .../databricks.yml.tmpl | 28 +++++++++++++++ .../out.test.toml | 3 ++ .../cluster_override_existing_key/output.txt | 36 +++++++++++++++++++ .../cluster_override_existing_key/script | 18 ++++++++++ .../cluster_override_existing_key/test.toml | 1 + bundle/configsync/patch.go | 15 ++++++++ bundle/configsync/patch_test.go | 21 +++++++++++ 7 files changed, 122 insertions(+) create mode 100644 acceptance/bundle/config-remote-sync/cluster_override_existing_key/databricks.yml.tmpl create mode 100644 acceptance/bundle/config-remote-sync/cluster_override_existing_key/out.test.toml create mode 100644 acceptance/bundle/config-remote-sync/cluster_override_existing_key/output.txt create mode 100644 acceptance/bundle/config-remote-sync/cluster_override_existing_key/script create mode 100644 acceptance/bundle/config-remote-sync/cluster_override_existing_key/test.toml diff --git a/acceptance/bundle/config-remote-sync/cluster_override_existing_key/databricks.yml.tmpl b/acceptance/bundle/config-remote-sync/cluster_override_existing_key/databricks.yml.tmpl new file mode 100644 index 00000000000..c12eefe4f7c --- /dev/null +++ b/acceptance/bundle/config-remote-sync/cluster_override_existing_key/databricks.yml.tmpl @@ -0,0 +1,28 @@ +bundle: + name: test-bundle-$UNIQUE_NAME + +# cluster_id makes OverrideCompute clear job_cluster_key, so the merged config +# has no value for it even though the YAML still declares it. + +resources: + jobs: + my_job: + job_clusters: + - job_cluster_key: shared + new_cluster: + spark_version: 13.3.x-scala2.12 + num_workers: 1 + - job_cluster_key: other + new_cluster: + spark_version: 13.3.x-scala2.12 + num_workers: 2 + tasks: + - task_key: main + job_cluster_key: shared + notebook_task: + notebook_path: /Users/{{workspace_user_name}}/nb + +targets: + dev: + mode: development + cluster_id: 0101-000000-override diff --git a/acceptance/bundle/config-remote-sync/cluster_override_existing_key/out.test.toml b/acceptance/bundle/config-remote-sync/cluster_override_existing_key/out.test.toml new file mode 100644 index 00000000000..8c2cb31de53 --- /dev/null +++ b/acceptance/bundle/config-remote-sync/cluster_override_existing_key/out.test.toml @@ -0,0 +1,3 @@ +Cloud = false +GOOS.windows = false +EnvMatrix.DMS = ["", "true"] diff --git a/acceptance/bundle/config-remote-sync/cluster_override_existing_key/output.txt b/acceptance/bundle/config-remote-sync/cluster_override_existing_key/output.txt new file mode 100644 index 00000000000..5fac361753b --- /dev/null +++ b/acceptance/bundle/config-remote-sync/cluster_override_existing_key/output.txt @@ -0,0 +1,36 @@ +Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle-[UNIQUE_NAME]/dev/files... +Created jobs.my_job +Files: 2 uploaded, 0 deleted +Resources: 1 created, 0 changed, 0 deleted, 0 unchanged + +=== Move the task to another job cluster remotely + +=== Sync replaces the job_cluster_key the YAML already has + +>>> [CLI] bundle config-remote-sync -t dev --save +Detected changes in 1 resource(s): + +Resource: resources.jobs.my_job + tasks[task_key='main'].existing_cluster_id: remove + tasks[task_key='main'].job_cluster_key: add + + + +>>> diff.py databricks.yml.backup databricks.yml +--- databricks.yml.backup ++++ databricks.yml +@@ -19,5 +19,5 @@ + tasks: + - task_key: main +- job_cluster_key: shared ++ job_cluster_key: other + notebook_task: + notebook_path: /Users/{{workspace_user_name}}/nb + +>>> [CLI] bundle destroy --auto-approve -t dev +The following resources will be deleted: + delete resources.jobs.my_job + +All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/test-bundle-[UNIQUE_NAME]/dev + +Destroy: 1 deleted diff --git a/acceptance/bundle/config-remote-sync/cluster_override_existing_key/script b/acceptance/bundle/config-remote-sync/cluster_override_existing_key/script new file mode 100644 index 00000000000..57d1b1f93f2 --- /dev/null +++ b/acceptance/bundle/config-remote-sync/cluster_override_existing_key/script @@ -0,0 +1,18 @@ +envsubst < databricks.yml.tmpl > databricks.yml +cleanup() { trace $CLI bundle destroy --auto-approve -t dev; } +trap cleanup EXIT +$CLI bundle deploy -t dev +job_id="$(read_id.py my_job)" + +title "Move the task to another job cluster remotely" +edit_resource.py jobs $job_id < Date: Tue, 24 Nov 2026 20:08:30 +0000 Subject: [PATCH 2/8] WIP: review round 1 --- bundle/configsync/patch.go | 47 ++++++++++++++++++++++----------- bundle/configsync/patch_test.go | 1 + 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/bundle/configsync/patch.go b/bundle/configsync/patch.go index ba2e3e47c14..87d4a0cde93 100644 --- a/bundle/configsync/patch.go +++ b/bundle/configsync/patch.go @@ -109,22 +109,18 @@ func applyChange(ctx context.Context, content []byte, fieldChange FieldChange) ( Value: fieldChange.Change.Value, }}) case OperationAdd: + opType := yamlpatch.OperationAdd + // The merged config can lack a key the file declares, e.g. when OverrideCompute + // clears job_cluster_key, so an add replaces an existing key as in RFC 6902. + if yamlKeyExists(content, fieldPathCandidate) { + opType = yamlpatch.OperationReplace + } modifiedContent, patchErr = patcher.Apply(content, yamlpatch.Patch{yamlpatch.Operation{ - Type: yamlpatch.OperationAdd, + Type: opType, Path: path, Value: fieldChange.Change.Value, }}) - // The merged config can lack a key the file declares, e.g. when OverrideCompute - // clears job_cluster_key, so an add replaces an existing key as in RFC 6902. - if isKeyExistsError(patchErr) { - modifiedContent, patchErr = patcher.Apply(content, yamlpatch.Patch{yamlpatch.Operation{ - Type: yamlpatch.OperationReplace, - Path: path, - Value: fieldChange.Change.Value, - }}) - } - // Collect parent path errors for later retry if patchErr != nil && isParentPathError(patchErr) { if missingPath, extractErr := extractMissingPath(patchErr); extractErr == nil { @@ -277,11 +273,6 @@ func isPathNotFoundError(err error) bool { return strings.Contains(msg, "does not exist") } -// isKeyExistsError checks if error indicates an add to a mapping key that is already there. -func isKeyExistsError(err error) bool { - return err != nil && strings.Contains(err.Error(), "already exists and can not be added") -} - // extractMissingPath extracts the missing path from error message like: // "op add /a/b/c/d: parent path /a/b does not exist" // Returns: "/a/b" @@ -419,6 +410,30 @@ func yamlChild(current *yaml.Node, part *structpath.PathNode) (child, keyNode *y return nil, nil } +// yamlKeyExists reports whether fieldPath ends at a mapping key the YAML already has. +// An add at a sequence index inserts rather than replaces, so only keys count. +func yamlKeyExists(content []byte, fieldPath string) bool { + pattern, err := structpath.ParsePattern(fieldPath) + if err != nil { + return false + } + if _, ok := pattern.StringKey(); !ok { + return false + } + var doc yaml.Node + if err := yaml.Unmarshal(content, &doc); err != nil || len(doc.Content) != 1 { + return false + } + current := doc.Content[0] + for _, part := range pattern.AsSlice() { + current, _ = yamlChild(current, (*structpath.PathNode)(part)) + if current == nil { + return false + } + } + return true +} + // clearFlowStyleAlongPath navigates the YAML tree along the given structpath, // clearing FlowStyle on every node from root to leaf (inclusive). func clearFlowStyleAlongPath(doc *yaml.Node, pathStr string) { diff --git a/bundle/configsync/patch_test.go b/bundle/configsync/patch_test.go index 4cd3350c696..d390d2d1963 100644 --- a/bundle/configsync/patch_test.go +++ b/bundle/configsync/patch_test.go @@ -481,6 +481,7 @@ func TestApplyChangeAddToExistingKey(t *testing.T) { }{ {"scalar", "tasks:\n - task_key: main\n job_cluster_key: old\n", "tasks[0].job_cluster_key", "tasks: [{task_key: main, job_cluster_key: value}]"}, {"null", "parameters:\n - name: p\n value:\n", "parameters[0].value", "parameters: [{name: p, value: value}]"}, + {"sequence index inserts", "parent:\n - a\n", "parent[0]", "parent: [value, a]"}, } { t.Run(tc.name, func(t *testing.T) { result, err := applyChange(t.Context(), []byte(tc.content), FieldChange{ From 97a26f0f000a9e0a22e1256a110593411140c1db Mon Sep 17 00:00:00 2001 From: "ilya.kuznetsov" Date: Tue, 24 Nov 2026 20:14:09 +0000 Subject: [PATCH 3/8] WIP: review round 2 --- .../databricks.yml.tmpl | 8 +++++ .../cluster_override_existing_key/output.txt | 23 +++++++++--- .../cluster_override_existing_key/script | 9 +++-- .../cleared_key_override/databricks.yml.tmpl | 36 +++++++++++++++++++ .../split/cleared_key_override/out.test.toml | 3 ++ .../split/cleared_key_override/output.txt | 35 ++++++++++++++++++ .../split/cleared_key_override/script | 18 ++++++++++ bundle/configsync/resolve.go | 11 ++++++ 8 files changed, 136 insertions(+), 7 deletions(-) create mode 100644 acceptance/bundle/config-remote-sync/split/cleared_key_override/databricks.yml.tmpl create mode 100644 acceptance/bundle/config-remote-sync/split/cleared_key_override/out.test.toml create mode 100644 acceptance/bundle/config-remote-sync/split/cleared_key_override/output.txt create mode 100644 acceptance/bundle/config-remote-sync/split/cleared_key_override/script diff --git a/acceptance/bundle/config-remote-sync/cluster_override_existing_key/databricks.yml.tmpl b/acceptance/bundle/config-remote-sync/cluster_override_existing_key/databricks.yml.tmpl index c12eefe4f7c..cc0155df7b4 100644 --- a/acceptance/bundle/config-remote-sync/cluster_override_existing_key/databricks.yml.tmpl +++ b/acceptance/bundle/config-remote-sync/cluster_override_existing_key/databricks.yml.tmpl @@ -4,6 +4,10 @@ bundle: # cluster_id makes OverrideCompute clear job_cluster_key, so the merged config # has no value for it even though the YAML still declares it. +variables: + cluster_key: + default: shared + resources: jobs: my_job: @@ -21,6 +25,10 @@ resources: job_cluster_key: shared notebook_task: notebook_path: /Users/{{workspace_user_name}}/nb + - task_key: by_variable + job_cluster_key: ${var.cluster_key} + notebook_task: + notebook_path: /Users/{{workspace_user_name}}/nb targets: dev: diff --git a/acceptance/bundle/config-remote-sync/cluster_override_existing_key/output.txt b/acceptance/bundle/config-remote-sync/cluster_override_existing_key/output.txt index 5fac361753b..cc38e1e3cb2 100644 --- a/acceptance/bundle/config-remote-sync/cluster_override_existing_key/output.txt +++ b/acceptance/bundle/config-remote-sync/cluster_override_existing_key/output.txt @@ -3,23 +3,25 @@ Created jobs.my_job Files: 2 uploaded, 0 deleted Resources: 1 created, 0 changed, 0 deleted, 0 unchanged -=== Move the task to another job cluster remotely +=== Move the tasks back to job clusters remotely -=== Sync replaces the job_cluster_key the YAML already has +=== Sync replaces the job_cluster_key the YAML already has and keeps the variable >>> [CLI] bundle config-remote-sync -t dev --save Detected changes in 1 resource(s): Resource: resources.jobs.my_job + tasks[task_key='by_variable'].existing_cluster_id: remove + tasks[task_key='by_variable'].job_cluster_key: replace tasks[task_key='main'].existing_cluster_id: remove - tasks[task_key='main'].job_cluster_key: add + tasks[task_key='main'].job_cluster_key: replace >>> diff.py databricks.yml.backup databricks.yml --- databricks.yml.backup +++ databricks.yml -@@ -19,5 +19,5 @@ +@@ -23,5 +23,5 @@ tasks: - task_key: main - job_cluster_key: shared @@ -27,6 +29,19 @@ Resource: resources.jobs.my_job notebook_task: notebook_path: /Users/{{workspace_user_name}}/nb +=== The override still clears job_cluster_key, so the next sync detects it again + +>>> [CLI] bundle config-remote-sync -t dev +Detected changes in 1 resource(s): + +Resource: resources.jobs.my_job + tasks[task_key='by_variable'].existing_cluster_id: remove + tasks[task_key='by_variable'].job_cluster_key: replace + tasks[task_key='main'].existing_cluster_id: remove + tasks[task_key='main'].job_cluster_key: replace + + + >>> [CLI] bundle destroy --auto-approve -t dev The following resources will be deleted: delete resources.jobs.my_job diff --git a/acceptance/bundle/config-remote-sync/cluster_override_existing_key/script b/acceptance/bundle/config-remote-sync/cluster_override_existing_key/script index 57d1b1f93f2..85c624bd967 100644 --- a/acceptance/bundle/config-remote-sync/cluster_override_existing_key/script +++ b/acceptance/bundle/config-remote-sync/cluster_override_existing_key/script @@ -4,15 +4,18 @@ trap cleanup EXIT $CLI bundle deploy -t dev job_id="$(read_id.py my_job)" -title "Move the task to another job cluster remotely" +title "Move the tasks back to job clusters remotely" edit_resource.py jobs $job_id <>> [CLI] bundle config-remote-sync -t dev --save +Detected changes in 1 resource(s): + +Resource: resources.jobs.my_job + tasks[task_key='main'].existing_cluster_id: remove + tasks[task_key='main'].job_cluster_key: replace + + + +>>> diff.py databricks.yml.backup databricks.yml +--- databricks.yml.backup ++++ databricks.yml +@@ -33,4 +33,4 @@ + tasks: + - task_key: main +- job_cluster_key: shared ++ job_cluster_key: other + max_retries: 1 + +>>> [CLI] bundle destroy --auto-approve -t dev +The following resources will be deleted: + delete resources.jobs.my_job + +All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/test-bundle-[UNIQUE_NAME]/dev + +Destroy: 1 deleted diff --git a/acceptance/bundle/config-remote-sync/split/cleared_key_override/script b/acceptance/bundle/config-remote-sync/split/cleared_key_override/script new file mode 100644 index 00000000000..4b53bcb8b11 --- /dev/null +++ b/acceptance/bundle/config-remote-sync/split/cleared_key_override/script @@ -0,0 +1,18 @@ +envsubst < databricks.yml.tmpl > databricks.yml +cleanup() { trace $CLI bundle destroy --auto-approve -t dev; } +trap cleanup EXIT +$CLI bundle deploy -t dev +job_id="$(read_id.py my_job)" + +title "Move the task to another job cluster remotely" +edit_resource.py jobs $job_id < Date: Tue, 24 Nov 2026 20:19:44 +0000 Subject: [PATCH 4/8] WIP: review round 2 fixes --- .../databricks.yml.tmpl | 21 ++++++++++++ .../top_level_field_both_blocks/out.test.toml | 3 ++ .../top_level_field_both_blocks/output.txt | 33 +++++++++++++++++++ .../split/top_level_field_both_blocks/script | 16 +++++++++ bundle/configsync/sequences.go | 9 ++++- 5 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 acceptance/bundle/config-remote-sync/split/top_level_field_both_blocks/databricks.yml.tmpl create mode 100644 acceptance/bundle/config-remote-sync/split/top_level_field_both_blocks/out.test.toml create mode 100644 acceptance/bundle/config-remote-sync/split/top_level_field_both_blocks/output.txt create mode 100644 acceptance/bundle/config-remote-sync/split/top_level_field_both_blocks/script diff --git a/acceptance/bundle/config-remote-sync/split/top_level_field_both_blocks/databricks.yml.tmpl b/acceptance/bundle/config-remote-sync/split/top_level_field_both_blocks/databricks.yml.tmpl new file mode 100644 index 00000000000..31d02caea81 --- /dev/null +++ b/acceptance/bundle/config-remote-sync/split/top_level_field_both_blocks/databricks.yml.tmpl @@ -0,0 +1,21 @@ +bundle: + name: test-bundle-$UNIQUE_NAME + +# max_concurrent_runs is outside any sequence and declared in both blocks of one +# file; the target's value wins the merge, so that is the one to replace. + +resources: + jobs: + my_job: + max_concurrent_runs: 1 + tasks: + - task_key: main + notebook_task: + notebook_path: /Users/{{workspace_user_name}}/nb + +targets: + dev: + resources: + jobs: + my_job: + max_concurrent_runs: 2 diff --git a/acceptance/bundle/config-remote-sync/split/top_level_field_both_blocks/out.test.toml b/acceptance/bundle/config-remote-sync/split/top_level_field_both_blocks/out.test.toml new file mode 100644 index 00000000000..8c2cb31de53 --- /dev/null +++ b/acceptance/bundle/config-remote-sync/split/top_level_field_both_blocks/out.test.toml @@ -0,0 +1,3 @@ +Cloud = false +GOOS.windows = false +EnvMatrix.DMS = ["", "true"] diff --git a/acceptance/bundle/config-remote-sync/split/top_level_field_both_blocks/output.txt b/acceptance/bundle/config-remote-sync/split/top_level_field_both_blocks/output.txt new file mode 100644 index 00000000000..89d45e9dac6 --- /dev/null +++ b/acceptance/bundle/config-remote-sync/split/top_level_field_both_blocks/output.txt @@ -0,0 +1,33 @@ +Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle-[UNIQUE_NAME]/dev/files... +Created jobs.my_job +Files: 2 uploaded, 0 deleted +Resources: 1 created, 0 changed, 0 deleted, 0 unchanged + +=== Change the field remotely + +=== Sync replaces the target's value + +>>> [CLI] bundle config-remote-sync -t dev --save +Detected changes in 1 resource(s): + +Resource: resources.jobs.my_job + max_concurrent_runs: replace + + + +>>> diff.py databricks.yml.backup databricks.yml +--- databricks.yml.backup ++++ databricks.yml +@@ -19,3 +19,3 @@ + jobs: + my_job: +- max_concurrent_runs: 2 ++ max_concurrent_runs: 10 + +>>> [CLI] bundle destroy --auto-approve -t dev +The following resources will be deleted: + delete resources.jobs.my_job + +All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/test-bundle-[UNIQUE_NAME]/dev + +Destroy: 1 deleted diff --git a/acceptance/bundle/config-remote-sync/split/top_level_field_both_blocks/script b/acceptance/bundle/config-remote-sync/split/top_level_field_both_blocks/script new file mode 100644 index 00000000000..c7b81294d13 --- /dev/null +++ b/acceptance/bundle/config-remote-sync/split/top_level_field_both_blocks/script @@ -0,0 +1,16 @@ +envsubst < databricks.yml.tmpl > databricks.yml +cleanup() { trace $CLI bundle destroy --auto-approve -t dev; } +trap cleanup EXIT +$CLI bundle deploy -t dev +job_id="$(read_id.py my_job)" + +title "Change the field remotely" +edit_resource.py jobs $job_id < Date: Tue, 24 Nov 2026 20:31:31 +0000 Subject: [PATCH 5/8] WIP: review round 3 fixes --- bundle/configsync/patch.go | 4 ++-- bundle/configsync/resolve.go | 16 +++++++++++----- cmd/bundle/config_remote_sync.go | 3 ++- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/bundle/configsync/patch.go b/bundle/configsync/patch.go index 87d4a0cde93..4edef8c43fc 100644 --- a/bundle/configsync/patch.go +++ b/bundle/configsync/patch.go @@ -110,8 +110,8 @@ func applyChange(ctx context.Context, content []byte, fieldChange FieldChange) ( }}) case OperationAdd: opType := yamlpatch.OperationAdd - // The merged config can lack a key the file declares, e.g. when OverrideCompute - // clears job_cluster_key, so an add replaces an existing key as in RFC 6902. + // A key the file writes as null is absent from the merged config, so the change + // arrives as an add; it replaces the existing key, as in RFC 6902. if yamlKeyExists(content, fieldPathCandidate) { opType = yamlpatch.OperationReplace } diff --git a/bundle/configsync/resolve.go b/bundle/configsync/resolve.go index 03b4aaec0d2..ad9e16ea6db 100644 --- a/bundle/configsync/resolve.go +++ b/bundle/configsync/resolve.go @@ -199,7 +199,8 @@ func adjustArrayIndex(path *structpath.PatternNode, scope string, operations map // the caller can record it: the command runs unattended, so a change that silently // disappears looks identical to one that was written. preResolved is the merged // config with ${...} references still literal, used to detect variable-reference -// ancestors. +// ancestors and to find fields a mutator cleared, which are replaced where the file +// declares them. func ResolveChanges(ctx context.Context, b *bundle.Bundle, configChanges Changes, preResolved dyn.Value) ([]FieldChange, int, error) { var result []FieldChange skipped := 0 @@ -293,11 +294,16 @@ func ResolveChanges(ctx context.Context, b *bundle.Bundle, configChanges Changes // A mutator can clear or rebuild a field the file declares (OverrideCompute // drops job_cluster_key), leaving no source location. The pre-resolved config // still has it, so the change replaces it in the block it is declared in. - if resolved.leaf.Location().File == "" && configChange.Operation != OperationRemove { + // Only a value written in a block counts: one from a YAML anchor has no key + // of its own to replace there. + if blocks != nil && resolved.leaf.Location().File == "" && configChange.Operation != OperationRemove && + !slices.ContainsFunc(resolved.steps, func(s sequenceStep) bool { return s.newElement }) { if declared, ok := preResolvedValueAt(preResolved, mergedIndexPath.String()); ok { - resolved.leaf = declared - resolved.operation = OperationReplace - configChange.Operation = OperationReplace + if _, inBlock := blocks.winningBlock(declared); inBlock { + resolved.leaf = declared + resolved.operation = OperationReplace + configChange.Operation = OperationReplace + } } } diff --git a/cmd/bundle/config_remote_sync.go b/cmd/bundle/config_remote_sync.go index afa879684c5..99d31b426b5 100644 --- a/cmd/bundle/config_remote_sync.go +++ b/cmd/bundle/config_remote_sync.go @@ -148,7 +148,8 @@ Examples: } // Loaded once and shared: ResolveChanges uses it to skip changes whose - // parent is a variable reference, RestoreVariableReferences to restore refs. + // parent is a variable reference and to find fields a mutator cleared, + // RestoreVariableReferences to restore refs. preResolved := configsync.LoadPreResolvedConfig(ctx, b) fieldChanges, skipped, err := configsync.ResolveChanges(ctx, b, detected, preResolved) From 12172924e845cea960fa30fc607d5c8c51081ea3 Mon Sep 17 00:00:00 2001 From: "ilya.kuznetsov" Date: Tue, 24 Nov 2026 23:31:02 +0000 Subject: [PATCH 6/8] Add merge-inherited keys as before and never replace anchored keys Co-authored-by: Isaac --- .../databricks.yml.tmpl | 41 +++++++++++++ .../cluster_override_merge_key/out.test.toml | 3 + .../cluster_override_merge_key/output.txt | 57 +++++++++++++++++++ .../cluster_override_merge_key/script | 18 ++++++ .../cluster_override_merge_key/test.toml | 1 + bundle/configsync/patch.go | 15 +++-- bundle/configsync/patch_test.go | 20 +++++++ bundle/configsync/resolve.go | 12 ++-- bundle/configsync/sequences.go | 18 +++++- 9 files changed, 174 insertions(+), 11 deletions(-) create mode 100644 acceptance/bundle/config-remote-sync/cluster_override_merge_key/databricks.yml.tmpl create mode 100644 acceptance/bundle/config-remote-sync/cluster_override_merge_key/out.test.toml create mode 100644 acceptance/bundle/config-remote-sync/cluster_override_merge_key/output.txt create mode 100644 acceptance/bundle/config-remote-sync/cluster_override_merge_key/script create mode 100644 acceptance/bundle/config-remote-sync/cluster_override_merge_key/test.toml diff --git a/acceptance/bundle/config-remote-sync/cluster_override_merge_key/databricks.yml.tmpl b/acceptance/bundle/config-remote-sync/cluster_override_merge_key/databricks.yml.tmpl new file mode 100644 index 00000000000..19eb537a3f3 --- /dev/null +++ b/acceptance/bundle/config-remote-sync/cluster_override_merge_key/databricks.yml.tmpl @@ -0,0 +1,41 @@ +bundle: + name: test-bundle-$UNIQUE_NAME + +# cluster_id makes OverrideCompute clear job_cluster_key. The tasks inherit it through +# merge keys, from an anchor outside resources and from one inside them. + +definitions: + outside: &outside + job_cluster_key: shared + +resources: + jobs: + my_job: + job_clusters: + - job_cluster_key: shared + new_cluster: + spark_version: 13.3.x-scala2.12 + num_workers: 1 + - job_cluster_key: other + new_cluster: + spark_version: 13.3.x-scala2.12 + num_workers: 2 + tasks: + - <<: *outside + task_key: from_outside + notebook_task: + notebook_path: /Users/{{workspace_user_name}}/nb + - <<: &inside + job_cluster_key: shared + task_key: defines_inside + notebook_task: + notebook_path: /Users/{{workspace_user_name}}/nb + - <<: *inside + task_key: from_inside + notebook_task: + notebook_path: /Users/{{workspace_user_name}}/nb + +targets: + dev: + mode: development + cluster_id: 0101-000000-override diff --git a/acceptance/bundle/config-remote-sync/cluster_override_merge_key/out.test.toml b/acceptance/bundle/config-remote-sync/cluster_override_merge_key/out.test.toml new file mode 100644 index 00000000000..8c2cb31de53 --- /dev/null +++ b/acceptance/bundle/config-remote-sync/cluster_override_merge_key/out.test.toml @@ -0,0 +1,3 @@ +Cloud = false +GOOS.windows = false +EnvMatrix.DMS = ["", "true"] diff --git a/acceptance/bundle/config-remote-sync/cluster_override_merge_key/output.txt b/acceptance/bundle/config-remote-sync/cluster_override_merge_key/output.txt new file mode 100644 index 00000000000..8d33f1f25b5 --- /dev/null +++ b/acceptance/bundle/config-remote-sync/cluster_override_merge_key/output.txt @@ -0,0 +1,57 @@ +Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle-[UNIQUE_NAME]/dev/files... +Created jobs.my_job +Files: 2 uploaded, 0 deleted +Resources: 1 created, 0 changed, 0 deleted, 0 unchanged + +=== Move the tasks back to job clusters remotely + +=== Sync adds job_cluster_key to the tasks that inherit it + +>>> [CLI] bundle config-remote-sync -t dev --save +Detected changes in 1 resource(s): + +Resource: resources.jobs.my_job + tasks[task_key='defines_inside'].existing_cluster_id: remove + tasks[task_key='defines_inside'].job_cluster_key: add + tasks[task_key='from_inside'].existing_cluster_id: remove + tasks[task_key='from_inside'].job_cluster_key: add + tasks[task_key='from_outside'].existing_cluster_id: remove + tasks[task_key='from_outside'].job_cluster_key: add + + + +>>> diff.py databricks.yml.backup databricks.yml +--- databricks.yml.backup ++++ databricks.yml +@@ -22,17 +22,20 @@ + num_workers: 2 + tasks: +- - <<: *outside ++ - !!merge <<: *outside + task_key: from_outside + notebook_task: + notebook_path: /Users/{{workspace_user_name}}/nb +- - <<: &inside ++ job_cluster_key: other ++ - !!merge <<: &inside + job_cluster_key: shared + task_key: defines_inside + notebook_task: + notebook_path: /Users/{{workspace_user_name}}/nb +- - <<: *inside ++ job_cluster_key: other ++ - !!merge <<: *inside + task_key: from_inside + notebook_task: + notebook_path: /Users/{{workspace_user_name}}/nb ++ job_cluster_key: other + + targets: + +>>> [CLI] bundle destroy --auto-approve -t dev +The following resources will be deleted: + delete resources.jobs.my_job + +All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/test-bundle-[UNIQUE_NAME]/dev + +Destroy: 1 deleted diff --git a/acceptance/bundle/config-remote-sync/cluster_override_merge_key/script b/acceptance/bundle/config-remote-sync/cluster_override_merge_key/script new file mode 100644 index 00000000000..b541a56d6c6 --- /dev/null +++ b/acceptance/bundle/config-remote-sync/cluster_override_merge_key/script @@ -0,0 +1,18 @@ +envsubst < databricks.yml.tmpl > databricks.yml +cleanup() { trace $CLI bundle destroy --auto-approve -t dev; } +trap cleanup EXIT +$CLI bundle deploy -t dev +job_id="$(read_id.py my_job)" + +title "Move the tasks back to job clusters remotely" +edit_resource.py jobs $job_id < Date: Tue, 24 Nov 2026 23:50:20 +0000 Subject: [PATCH 7/8] Skip anchors inside replaced values and anchored winners, and keep complex variable references Co-authored-by: Isaac --- .../databricks.yml.tmpl | 9 +++++ .../cluster_override_existing_key/output.txt | 8 +++- .../cluster_override_existing_key/script | 7 +++- .../databricks.yml.tmpl | 22 +++++++++++ .../anchored_override_field/out.test.toml | 3 ++ .../split/anchored_override_field/output.txt | 38 +++++++++++++++++++ .../split/anchored_override_field/script | 17 +++++++++ bundle/configsync/patch.go | 13 +++++-- bundle/configsync/patch_test.go | 1 + bundle/configsync/resolve.go | 17 +++++++++ bundle/configsync/sequences.go | 14 ++++--- 11 files changed, 136 insertions(+), 13 deletions(-) create mode 100644 acceptance/bundle/config-remote-sync/split/anchored_override_field/databricks.yml.tmpl create mode 100644 acceptance/bundle/config-remote-sync/split/anchored_override_field/out.test.toml create mode 100644 acceptance/bundle/config-remote-sync/split/anchored_override_field/output.txt create mode 100644 acceptance/bundle/config-remote-sync/split/anchored_override_field/script diff --git a/acceptance/bundle/config-remote-sync/cluster_override_existing_key/databricks.yml.tmpl b/acceptance/bundle/config-remote-sync/cluster_override_existing_key/databricks.yml.tmpl index cc0155df7b4..38ebb44dd69 100644 --- a/acceptance/bundle/config-remote-sync/cluster_override_existing_key/databricks.yml.tmpl +++ b/acceptance/bundle/config-remote-sync/cluster_override_existing_key/databricks.yml.tmpl @@ -7,6 +7,11 @@ bundle: variables: cluster_key: default: shared + cluster: + type: complex + default: + spark_version: 13.3.x-scala2.12 + num_workers: 1 resources: jobs: @@ -29,6 +34,10 @@ resources: job_cluster_key: ${var.cluster_key} notebook_task: notebook_path: /Users/{{workspace_user_name}}/nb + - task_key: by_complex_variable + new_cluster: ${var.cluster} + notebook_task: + notebook_path: /Users/{{workspace_user_name}}/nb targets: dev: diff --git a/acceptance/bundle/config-remote-sync/cluster_override_existing_key/output.txt b/acceptance/bundle/config-remote-sync/cluster_override_existing_key/output.txt index cc38e1e3cb2..791fb3d8d54 100644 --- a/acceptance/bundle/config-remote-sync/cluster_override_existing_key/output.txt +++ b/acceptance/bundle/config-remote-sync/cluster_override_existing_key/output.txt @@ -5,12 +5,14 @@ Resources: 1 created, 0 changed, 0 deleted, 0 unchanged === Move the tasks back to job clusters remotely -=== Sync replaces the job_cluster_key the YAML already has and keeps the variable +=== Sync replaces the job_cluster_key the YAML already has and keeps the variables >>> [CLI] bundle config-remote-sync -t dev --save Detected changes in 1 resource(s): Resource: resources.jobs.my_job + tasks[task_key='by_complex_variable'].existing_cluster_id: remove + tasks[task_key='by_complex_variable'].new_cluster: skip tasks[task_key='by_variable'].existing_cluster_id: remove tasks[task_key='by_variable'].job_cluster_key: replace tasks[task_key='main'].existing_cluster_id: remove @@ -21,7 +23,7 @@ Resource: resources.jobs.my_job >>> diff.py databricks.yml.backup databricks.yml --- databricks.yml.backup +++ databricks.yml -@@ -23,5 +23,5 @@ +@@ -28,5 +28,5 @@ tasks: - task_key: main - job_cluster_key: shared @@ -35,6 +37,8 @@ Resource: resources.jobs.my_job Detected changes in 1 resource(s): Resource: resources.jobs.my_job + tasks[task_key='by_complex_variable'].existing_cluster_id: remove + tasks[task_key='by_complex_variable'].new_cluster: skip tasks[task_key='by_variable'].existing_cluster_id: remove tasks[task_key='by_variable'].job_cluster_key: replace tasks[task_key='main'].existing_cluster_id: remove diff --git a/acceptance/bundle/config-remote-sync/cluster_override_existing_key/script b/acceptance/bundle/config-remote-sync/cluster_override_existing_key/script index 85c624bd967..ebd93d2dc82 100644 --- a/acceptance/bundle/config-remote-sync/cluster_override_existing_key/script +++ b/acceptance/bundle/config-remote-sync/cluster_override_existing_key/script @@ -8,10 +8,13 @@ title "Move the tasks back to job clusters remotely" edit_resource.py jobs $job_id <>> [CLI] bundle config-remote-sync -t dev --save +Detected changes in 1 resource(s): + +Resource: resources.jobs.my_job + max_concurrent_runs: replace + + + +>>> diff.py databricks.yml.backup databricks.yml +--- databricks.yml.backup ++++ databricks.yml +@@ -8,5 +8,5 @@ + jobs: + my_job: +- max_concurrent_runs: 1 ++ max_concurrent_runs: 10 + tasks: + - task_key: main + +>>> [CLI] bundle validate -t dev -o json +2 + +>>> [CLI] bundle destroy --auto-approve -t dev +The following resources will be deleted: + delete resources.jobs.my_job + +All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/test-bundle-[UNIQUE_NAME]/dev + +Destroy: 1 deleted diff --git a/acceptance/bundle/config-remote-sync/split/anchored_override_field/script b/acceptance/bundle/config-remote-sync/split/anchored_override_field/script new file mode 100644 index 00000000000..22797c4c44c --- /dev/null +++ b/acceptance/bundle/config-remote-sync/split/anchored_override_field/script @@ -0,0 +1,17 @@ +envsubst < databricks.yml.tmpl > databricks.yml +cleanup() { trace $CLI bundle destroy --auto-approve -t dev; } +trap cleanup EXIT +$CLI bundle deploy -t dev +job_id="$(read_id.py my_job)" + +title "Change the field remotely" +edit_resource.py jobs $job_id < Date: Tue, 24 Nov 2026 23:53:46 +0000 Subject: [PATCH 8/8] Leave a change unapplied when its winning definition cannot be replaced safely Co-authored-by: Isaac --- .../split/anchored_override_field/output.txt | 13 ++----------- .../split/anchored_override_field/script | 4 ++-- bundle/configsync/sequences.go | 10 +++++++--- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/acceptance/bundle/config-remote-sync/split/anchored_override_field/output.txt b/acceptance/bundle/config-remote-sync/split/anchored_override_field/output.txt index fb5c880c347..d517442f43b 100644 --- a/acceptance/bundle/config-remote-sync/split/anchored_override_field/output.txt +++ b/acceptance/bundle/config-remote-sync/split/anchored_override_field/output.txt @@ -5,7 +5,7 @@ Resources: 1 created, 0 changed, 0 deleted, 0 unchanged === Change the field remotely -=== Sync keeps the target's anchor +=== Sync leaves the anchored target value unapplied >>> [CLI] bundle config-remote-sync -t dev --save Detected changes in 1 resource(s): @@ -16,18 +16,9 @@ Resource: resources.jobs.my_job >>> diff.py databricks.yml.backup databricks.yml ---- databricks.yml.backup -+++ databricks.yml -@@ -8,5 +8,5 @@ - jobs: - my_job: -- max_concurrent_runs: 1 -+ max_concurrent_runs: 10 - tasks: - - task_key: main >>> [CLI] bundle validate -t dev -o json -2 +{"max_concurrent_runs":2,"timeout_seconds":2} >>> [CLI] bundle destroy --auto-approve -t dev The following resources will be deleted: diff --git a/acceptance/bundle/config-remote-sync/split/anchored_override_field/script b/acceptance/bundle/config-remote-sync/split/anchored_override_field/script index 22797c4c44c..47c15a94531 100644 --- a/acceptance/bundle/config-remote-sync/split/anchored_override_field/script +++ b/acceptance/bundle/config-remote-sync/split/anchored_override_field/script @@ -9,9 +9,9 @@ edit_resource.py jobs $job_id <