Merge pull request #59594 from liggitt/wait-for-patch

Automatic merge from submit-queue (batch tested with PRs 59447, 59594, 59651, 59389). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Workaround patch using cached version in TestPatch

Deflakes https://github.com/kubernetes/kubernetes/issues/42644 but does not resolve the underlying issue

```release-note
NONE
```
This commit is contained in:
Kubernetes Submit Queue 2018-02-09 12:21:32 -08:00 committed by GitHub
commit 5898d63092
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -578,6 +578,17 @@ func TestPatch(t *testing.T) {
t.Fatalf("unexpected error: %v", err)
}
// this call waits for the resourceVersion to be reached in the cache before returning.
// We need to do this because the patch gets its initial object from the storage, and the cache serves that.
// If it is out of date, then our initial patch is applied to an old resource version, which conflicts
// and then the updated object shows a conflicting diff, which permanently fails the patch.
// This gives expected stability in the patch without retrying on an known number of conflicts below in the test.
// See https://issue.k8s.io/42644
_, err = noxuNamespacedResourceClient.Get("foo", metav1.GetOptions{ResourceVersion: createdNoxuInstance.GetResourceVersion()})
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
// a patch with no change
createdNoxuInstance, err = noxuNamespacedResourceClient.Patch("foo", types.MergePatchType, patch)
if err != nil {