From cb24bd03f7d9e3cf1dba30a29e7349572478077e Mon Sep 17 00:00:00 2001 From: Jordan Liggitt Date: Thu, 8 Feb 2018 16:48:31 -0500 Subject: [PATCH] Workaround patch using cached version in TestPatch --- .../test/integration/basic_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/staging/src/k8s.io/apiextensions-apiserver/test/integration/basic_test.go b/staging/src/k8s.io/apiextensions-apiserver/test/integration/basic_test.go index 36801636ea1..afb6d1b495e 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/test/integration/basic_test.go +++ b/staging/src/k8s.io/apiextensions-apiserver/test/integration/basic_test.go @@ -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 {