Skip to content

Commit 3207693

Browse files
committed
fix: strategic merge patch delete for map keys
When a map key is deleted, it should be deleted as a whole. Before the fix it was zeroing out map value by key. Fixes #9325 Signed-off-by: Andrey Smirnov <[email protected]> (cherry picked from commit 18daedb)
1 parent 7478db7 commit 3207693

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

pkg/machinery/config/configloader/internal/decoder/selector.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ func deleteForPath(val reflect.Value, path []string, key, value string) error {
187187

188188
if idx := val.MapIndex(searchForVal); idx.IsValid() {
189189
if len(path) == 0 {
190-
val.SetMapIndex(searchForVal, reflect.Zero(valType.Elem()))
190+
val.SetMapIndex(searchForVal, reflect.Value{})
191191

192192
return nil
193193
}

pkg/machinery/config/configpatcher/testdata/patchdelete/controlplane_expected.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ machine:
2626
hostDNS:
2727
enabled: true
2828
forwardKubeDNSToHost: true
29-
nodeLabels:
30-
node.kubernetes.io/exclude-from-external-load-balancers: ""
3129
cluster:
3230
id: 0raF93qnkMvF-FZNuvyGozXNdLiT2FOWSlyBaW4PR-w=
3331
secret: pofHbABZq7VXuObsdLdy/bHmz6hlMHZ3p8+6WKrv1ic=

pkg/machinery/config/configpatcher/testdata/patchdelete/strategic2.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@ cluster:
44
admissionControl:
55
- name: PodSecurity
66
$patch: delete
7+
machine:
8+
nodeLabels:
9+
node.kubernetes.io/exclude-from-external-load-balancers:
10+
$patch: delete

0 commit comments

Comments
 (0)