kyaml: fix $patch directives ignored with ListPrepend merge#6147
Conversation
|
Welcome @rm3l! |
|
Hi @rm3l. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: rm3l The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
886e32b to
de5a438
Compare
When merging associative lists with ListIncreaseDirection set to MergeOptionsListPrepend, strategic merge patch directives ($patch: replace, $patch: delete) on individual list elements were silently ignored. The root cause was that appendListNode was called with swapped arguments for the prepend case, causing original dest elements to overwrite already-merged results in itemsToBeAdded. Replace appendListNode with a new appendMissingListNode function in the prepend path. This function only appends elements from dest that are not already present in the merged results, preserving $patch directive outcomes. Signed-off-by: Armel Soro <asoro@redhat.com>
de5a438 to
ec4d22f
Compare
$patch directives ignored with ListPrepend merge
Summary
Fixes #6146
$patch: replaceand$patch: deletedirectives on individual associative list elements were silently ignored whenListIncreaseDirectionwas set toMergeOptionsListPrependsetAssociativeSequenceElements, the ListPrepend path calledappendListNode(itemsToBeAdded, dest, ...)with swapped arguments, causingElementSetterto overwrite already-merged items with unmerged originals from destappendMissingListNodethat only appends elements not already present in the destination, preserving merged resultsNOTE:
I've created a branch in the repro repo using the patched kyaml from this PR, and it seems to be fixing the issue: https://github.com/rm3l/kyaml-listprepend-bug/tree/fix/use-patched-kyaml