Repository navigation
Skip config-remote-sync key adds that would hide keys inherited through YAML merge keys - #8175
ilyakuz-db wants to merge 7 commits into
Conversation
Co-authored-by: Isaac <no-reply@databricks.com>
…ason Co-authored-by: Isaac <no-reply@databricks.com>
aws: TestAccept/bundle/config-remote-sync/cli_defaults TestAccept/bundle/config-remote-sync/config_edits TestAccept/bundle/config-remote-sync/job_fields TestAccept/bundle/config-remote-sync/multiple_files aws: TestAccept/bundle/config-remote-sync/pipeline_fields TestAccept/bundle/config-remote-sync/target_override TestAccept/bundle/config-remote-sync/yaml_anchors Co-authored-by: Isaac <no-reply@databricks.com>
Regression test report ✅Commit: Selected 1 changed tests (limit=20, 0 not selected) 16 tests: regression=2 unreleased=2 coverage=12 failing=0
TestAccept/bundle/config-remote-sync/merge_key_inherited/DMS=: branch ✅ | main (bfcdd1f) ❌ | latest (v1.28.0) ❌main (bfcdd1f): latest (v1.28.0): TestAccept/bundle/config-remote-sync/merge_key_inherited/DMS=true: branch ✅ | main (bfcdd1f) ❌ | latest (v1.28.0) ❌main (bfcdd1f): latest (v1.28.0): TestAccept/bundle/config-remote-sync/yaml_anchors/DMS=: branch ✅ | main (bfcdd1f) ✅ | latest (v1.28.0) ❌latest (v1.28.0): TestAccept/bundle/config-remote-sync/yaml_anchors/DMS=true: branch ✅ | main (bfcdd1f) ✅ | latest (v1.28.0) ❌latest (v1.28.0): |
There was a problem hiding this comment.
Automated review at 55b5823. Each finding was verified against the code.
No blocking issues found. 3 non-blocking comment(s) and 1 question(s) below.
This PR makes config-remote-sync check each new-key add, including a replace of an undeclared field, against the file before writing it. An add is skipped when it would create a mapping next to a <<: *anchor that already supplies that mapping, or when it would land in a mapping shared through an anchor. The fix for the inherited-mapping case looks right and the acceptance test shows it. Three things to address: a mapping that has an anchor nothing aliases is now skipped on every run, cases unrelated to anchors are skipped under the anchor reason, and there is no changelog fragment.
Questions
addsOnlyKeycopies the order in whichapplyChangetries an add (addYAML, thenaddThroughNullAncestor, thenaddMissingAncestors), and the description says the two must stay in step. Nothing inapplyChangementions this, and the copy already differs: tiers 1 and 2 don't checknestYAMLValueor the container kind thataddYAMLChildneeds. Sox.list[1].kwithlistmissing still passes the check and then fails the edit. Could the shared and merge-supplied checks go intoaddYAMLandaddMissingAncestorsthemselves (asaddThroughNullAncestoralready does for shared nulls) and surface as a typed skip? Or could both use one function that picks the landing path, or at least carry a keep-in-sync note? (non-blocking)
Comments outside the changed lines
- [nice to have]
bundle/configsync/resolve.go: This changes what users see: adds that used to be written (and could drop an inheritednotebook_path, or spread a key to every task that merges an anchor) are now skipped with a new reason, and some adds that failed the whole sync are now skipped. Can you add a.nextchanges/bundles/entry for it?
| if landingPath == nil { | ||
| return false | ||
| } | ||
| return !landing.shared && (tier < 2 || !mergeSupplies(landing.node, (*structpath.PathNode)(landingPath.AsSlice()[landing.depth]))) |
There was a problem hiding this comment.
[nice to have] walkYAMLPath sets shared for any node with an anchor, whether or not something aliases it, so this now rejects adds that are safe. Example: a task - &base_task with task_key: a_task, no *base_task in the file, and a remote that adds timeout_seconds. On main the key is written. Here it is skipped with the anchor reason, and the drift comes back on every later run with no way to sync it. The new branch at resolve.go:496 also sends undeclared-field replaces (CLI defaults) through this check, so they get skipped the same way. Could we count a mapping as shared only when an alias to its anchor exists in the document? Or is matching the replace behaviour worth this?
There was a problem hiding this comment.
[AI] Fixed in 4ed4d6c: for a new key add, a mapping now counts as shared only when an alias in the file refers to it or to a mapping on its path. An add under an anchor nothing aliases, such as timeout_seconds on a lone - &base_task, is written again, and so are the CLI-default replaces that turn into adds.
🤖 Factory-generated comment. I still review the code and double-check every claim myself.
[factory:30/254]| } | ||
| writePath, altWritePath := writeAddress(blocks, block, target, path) | ||
| if !docs.addsOnlyKey(file, writePath, altWritePath) { | ||
| return nil, "the mapping it would be added to is shared or inherited through a YAML anchor" |
There was a problem hiding this comment.
[nice to have] Every false from addsOnlyKey gets this one reason. That includes a walk that stops at a non-null scalar (patch.go:389-390), e.g. new_cluster: ${var.cluster} with a remote add under new_cluster, and paths that no candidate reaches (patch.go:396-397). In those cases nothing is shared or inherited. On main they failed with an edit error that named the cause. Now they are skipped quietly, and the message sends the user looking for anchors that may not exist. Could addsOnlyKey return a reason, so the scalar and no-landing cases get their own text?
There was a problem hiding this comment.
[AI] Fixed in 4ed4d6c: an add whose parent the file sets to a scalar, such as new_cluster: ${var.cluster}, is skipped with the file sets a parent of it to a scalar. The anchor reason is left for adds into an aliased mapping, next to a merge key that supplies the mapping, or onto an anchored value the edit will not replace.
🤖 Factory-generated comment. I still review the code and double-check every claim myself.
[factory:30/254]
✅ Integration test reportCommit: 5e45a05
8 interesting tests: 7 MISS, 1 RECOVERED
Top 3 slowest tests (at least 2 minutes):
|
|
check if this is still needed after vendor patcher replacement and request review |
…n skip reason Co-authored-by: Isaac <no-reply@databricks.com>
aws: TestAccept/bundle/config-remote-sync/cli_defaults TestAccept/bundle/config-remote-sync/config_edits TestAccept/bundle/config-remote-sync/job_fields TestAccept/bundle/config-remote-sync/multiple_files aws: TestAccept/bundle/config-remote-sync/pipeline_fields TestAccept/bundle/config-remote-sync/target_override TestAccept/bundle/config-remote-sync/yaml_anchors Co-authored-by: Isaac <no-reply@databricks.com>
|
[AI] Still needed. The patcher replacement (#8169) is this PR's base, and nothing in On the review summary: the check stays at resolve time, because a failed edit aborts the whole sync and a change with several destinations has to be skipped as a whole before the index bookkeeping. 🤖 Factory-generated comment. I still review the code and double-check every claim myself. [factory:30/254] |
| @@ -492,6 +493,17 @@ func writtenDestinations(docs sourceDocs, blocks *blockResolver, target string, | |||
| case !isDefinedInConfig && operation == OperationAdd && !addressesKey && block != nil: | |||
There was a problem hiding this comment.
A new element in a list shared through an alias lands in the anchor, so each job using it gains it. Should element adds skip too, or is this intended?
| case !isDefinedInConfig && operation == OperationAdd && !addressesKey && block != nil: | ||
| // A new element goes into its sequence, which the block has to write. | ||
| file = block.file | ||
| case !isDefinedInConfig && addressesKey && operation != OperationRemove: |
There was a problem hiding this comment.
No test reaches the replace half of this case: limiting it to adds keeps every test green. Could one cover a replace of an undeclared field under a shared mapping?
…lace Co-authored-by: Isaac <no-reply@databricks.com>
aws: TestAccept/bundle/config-remote-sync/cli_defaults TestAccept/bundle/config-remote-sync/config_edits TestAccept/bundle/config-remote-sync/job_fields TestAccept/bundle/config-remote-sync/multiple_files aws: TestAccept/bundle/config-remote-sync/pipeline_fields TestAccept/bundle/config-remote-sync/target_override TestAccept/bundle/config-remote-sync/yaml_anchors Co-authored-by: Isaac <no-reply@databricks.com>
Changes
config-remote-syncnow checks a remote add of a new key against the file before writing it. This also covers a replace of a field the file does not declare, which is written as an add. The add is skipped, with the reasonthe mapping it would be added to is shared or inherited through a YAML anchor, when it would:<<: *anchor) that already supplies that mapping, which hides every key inherited under it;An add under a parent the file sets to a scalar, such as
new_cluster: ${var.cluster}, is skipped with its own reason,the file sets a parent of it to a scalar, instead of failing the whole sync.A new element in a list that an alias refers to, or that is reached through one, is skipped too, with the reason
the list it would be added to is shared through a YAML anchor, since it would show up everywhere the alias is used.An add into a mapping the file writes itself is still written, also when that mapping has a merge key or an anchor nothing aliases.
Why
Take a task
- <<: *base_taskthat has nonotebook_taskof its own. A base parameter added on the remote made the sync writenotebook_task: {base_parameters: {added: c}}next to the merge key, so the task lost itsnotebook_pathand the inherited parameters. In the same way, a new key on the task that holds the anchor showed up on every task that merges it. #8048 handled removes, replaces, renames and new elements on inherited keys, and listed new-key adds as a known gap.The check follows the order in which
applyChangetries an add (an existing mapping, then a null ancestor, then the ancestors it creates), so the two have to stay in step, as a note onapplyChangesays. A mapping counts as shared only when an alias refers to it or to a mapping on its path: an anchor nothing aliases shares nothing.Tests
I extended
config-remote-sync/merge_key_inherited. On main, the new add onc_taskdrops itsnotebook_path(validate warns about it), and the add ona_taskshows up onc_tasktoo. With this change both are skipped and the effective config keeps the inherited fields, while the same add onb_task, which writes its ownbase_parametersnext to<<:, is still written. It also editsother_job, whichmy_jobmerges: a new task there, and a newmax_concurrent_runs, which dev mode sets and the file does not declare, so it arrives as a replace. On mainmy_jobgains the task; now both are skipped andmy_jobkeeps its tasks andmax_concurrent_runs. Unit cases for the check, including an anchor nothing aliases and a scalar parent, are inbundle/configsync/patch_test.go. The configsync unit tests, everyconfig-remote-syncand telemetryconfig-remote-syncacceptance test, and lint pass locally. The head commit requests 7config-remote-synccloud tests on aws;merge_key_inheriteditself runs locally only.7ebd0177ebd017RIGHT-SIZED: skips unsafe adds where the sync already decides skips5e45a05(latest)5e45a05(latest)c85744b5e45a05(latest)✅ success · ⏳ pending ·⚠️ warning · ❌ failed · ➖ n/a
This pull request and its description were written by Isaac.