• Kubernetes Submit Queue's avatar
    Merge pull request #43871 from liggitt/patch-mutation · 64973188
    Kubernetes Submit Queue authored
    Automatic merge from submit-queue (batch tested with PRs 43871, 44053)
    
    Fix original object mutation on patch retry
    
    When applying a patch, the original state of the object and patch are captured so that retries can determine if an overlapping update was made to the object, and the patch API call should abort with a conflict.
    
    However, the `strategicPatchObject -> applyPatchToObject -> StrategicMergeMapPatch -> mergeMap` call mutates both the original object map and the patch map, making them unsuitable for reusing for subsequent calls.
    
    We saw this in a [downstream test](https://github.com/openshift/origin/blob/master/test/integration/patch_test.go) that exercises patch conflict retries, where the data being submitted in a patch was showing up in the original object data map.
    
    Since mergeMap *also* mutates the patch map passed in (deletes patch directives as it encounters them), we *also* cannot reuse the patch map in `applyPatchToObject` once it has been used.
    
    This PR:
    * Builds `originalObjMap` separate from the initial patch application for later use in conflict detection
    * Changes the `originalPatchMap` to a helper that returns a fresh map from original sources
    * Adds an integration test that exercises retry of non-overlapping patches with patches containing `$patch` directives
    64973188
Name
Last commit
Last update
..
e2e Loading commit data...
e2e_federation Loading commit data...
e2e_node Loading commit data...
fixtures Loading commit data...
images Loading commit data...
integration Loading commit data...
kubemark Loading commit data...
list Loading commit data...
soak Loading commit data...
utils Loading commit data...
BUILD Loading commit data...
OWNERS Loading commit data...
test_owners.csv Loading commit data...