Merge pull request #35647 from ymqytw/patch_primitive_list

Automatic merge from submit-queue

Fix strategic patch for list of primitive type with merge sementic

Fix strategic patch for list of primitive type when the patch strategy is `merge`.
Before: we cannot replace or delete an item in a list of primitive, e.g. string, when the patch strategy is `merge`. It will always append new items to the list.
This patch will generate a map to update the list of primitive type.
The server with this patch will accept either a new patch or an old patch.
The client will found out the APIserver version before generate the patch.

Fixes #35163, #32398

cc: @pwittrock @fabianofranz 

``` release-note
Fix strategic patch for list of primitive type when patch strategy is `merge` to remove deleted objects.
```
This commit is contained in:
Kubernetes Submit Queue
2016-11-11 14:36:44 -08:00
committed by GitHub
27 changed files with 2659 additions and 1661 deletions

View File

@@ -59,6 +59,10 @@ type nodeStatusUpdater struct {
}
func (nsu *nodeStatusUpdater) UpdateNodeStatuses() error {
smPatchVersion, err := strategicpatch.GetServerSupportedSMPatchVersion(nsu.kubeClient.Discovery())
if err != nil {
return err
}
nodesToUpdate := nsu.actualStateOfWorld.GetVolumesToReportAttached()
for nodeName, attachedVolumes := range nodesToUpdate {
nodeObj, exists, err := nsu.nodeInformer.GetStore().GetByKey(string(nodeName))
@@ -108,7 +112,7 @@ func (nsu *nodeStatusUpdater) UpdateNodeStatuses() error {
}
patchBytes, err :=
strategicpatch.CreateStrategicMergePatch(oldData, newData, node)
strategicpatch.CreateStrategicMergePatch(oldData, newData, node, smPatchVersion)
if err != nil {
return fmt.Errorf(
"failed to CreateStrategicMergePatch for node %q. %v",