Unverified Commit 631b7665 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #66169 from liggitt/patch-retry-1.10

Automatic merge from submit-queue. Remove patch retry conflict detection Minimal backport of #63146 Fixes #58002 Fixes spurious patch errors for CRDs Fixes patch errors for nodes when the watch cache has a persistently stale version of an object ```release-note fixes spurious "meaningful conflict" error encountered by nodes attempting to update status, which could cause them to be considered unready ```
parents 9beecb96 d8cac182
...@@ -173,18 +173,20 @@ func patchResource( ...@@ -173,18 +173,20 @@ func patchResource(
namespace := request.NamespaceValue(ctx) namespace := request.NamespaceValue(ctx)
var lastConflictErr error
// applyPatch is called every time GuaranteedUpdate asks for the updated object,
// and is given the currently persisted object as input.
applyPatch := func(_ request.Context, _, currentObject runtime.Object) (runtime.Object, error) {
// make these local vars so every patch attempt is handled as if it were the first attempt
var ( var (
originalObjJS []byte originalObjJS []byte
originalPatchedObjJS []byte originalPatchedObjJS []byte
originalObjMap map[string]interface{} originalObjMap map[string]interface{}
getOriginalPatchMap func() (map[string]interface{}, error) getOriginalPatchMap func() (map[string]interface{}, error)
lastConflictErr error
originalResourceVersion string originalResourceVersion string
) )
// applyPatch is called every time GuaranteedUpdate asks for the updated object,
// and is given the currently persisted object as input.
applyPatch := func(_ request.Context, _, currentObject runtime.Object) (runtime.Object, error) {
// Make sure we actually have a persisted currentObject // Make sure we actually have a persisted currentObject
trace.Step("About to apply patch") trace.Step("About to apply patch")
if hasUID, err := hasUID(currentObject); err != nil { if hasUID, err := hasUID(currentObject); err != nil {
......
...@@ -533,8 +533,7 @@ func TestPatchResourceWithConflict(t *testing.T) { ...@@ -533,8 +533,7 @@ func TestPatchResourceWithConflict(t *testing.T) {
startingPod: &example.Pod{}, startingPod: &example.Pod{},
changedPod: &example.Pod{}, changedPod: &example.Pod{},
updatePod: &example.Pod{}, updatePod: &example.Pod{},
expectedPod: &example.Pod{},
expectedError: `Operation cannot be fulfilled on pods.example.apiserver.k8s.io "foo": existing 2, new 1`,
} }
tc.startingPod.Name = name tc.startingPod.Name = name
...@@ -558,6 +557,13 @@ func TestPatchResourceWithConflict(t *testing.T) { ...@@ -558,6 +557,13 @@ func TestPatchResourceWithConflict(t *testing.T) {
tc.updatePod.APIVersion = examplev1.SchemeGroupVersion.String() tc.updatePod.APIVersion = examplev1.SchemeGroupVersion.String()
tc.updatePod.Spec.NodeName = "anywhere" tc.updatePod.Spec.NodeName = "anywhere"
tc.expectedPod.Name = name
tc.expectedPod.Namespace = namespace
tc.expectedPod.UID = uid
tc.expectedPod.ResourceVersion = "2"
tc.expectedPod.APIVersion = examplev1.SchemeGroupVersion.String()
tc.expectedPod.Spec.NodeName = "there"
tc.Run(t) tc.Run(t)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment