From 3dc7098cae4c699e30ed9ae85005446f8322fe99 Mon Sep 17 00:00:00 2001 From: Gaurav Singh Date: Sun, 17 May 2020 17:51:49 -0400 Subject: [PATCH 1/3] Fix data race in cacher whitebox test Signed-off-by: Gaurav Singh --- .../k8s.io/apiserver/pkg/storage/cacher/cacher_whitebox_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher_whitebox_test.go b/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher_whitebox_test.go index 18abd0a602f..e8b75048982 100644 --- a/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher_whitebox_test.go +++ b/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher_whitebox_test.go @@ -681,7 +681,7 @@ func testCacherSendBookmarkEvents(t *testing.T, allowWatchBookmarks, expectedBoo go func() { deadline := time.Now().Add(time.Second) for i := 0; time.Now().Before(deadline); i++ { - err = cacher.watchCache.Add(&examplev1.Pod{ + err := cacher.watchCache.Add(&examplev1.Pod{ ObjectMeta: metav1.ObjectMeta{ Name: fmt.Sprintf("pod-%d", i), Namespace: "ns", From 549214ca8c6f7e05fcbb0c8c045251819b039947 Mon Sep 17 00:00:00 2001 From: Gaurav Singh Date: Sun, 17 May 2020 17:54:28 -0400 Subject: [PATCH 2/3] Fix bug Signed-off-by: Gaurav Singh --- .../apiserver/pkg/storage/cacher/cacher_whitebox_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher_whitebox_test.go b/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher_whitebox_test.go index e8b75048982..a8fc0670823 100644 --- a/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher_whitebox_test.go +++ b/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher_whitebox_test.go @@ -680,8 +680,9 @@ func testCacherSendBookmarkEvents(t *testing.T, allowWatchBookmarks, expectedBoo resourceVersion := uint64(1000) go func() { deadline := time.Now().Add(time.Second) + var err error for i := 0; time.Now().Before(deadline); i++ { - err := cacher.watchCache.Add(&examplev1.Pod{ + err = cacher.watchCache.Add(&examplev1.Pod{ ObjectMeta: metav1.ObjectMeta{ Name: fmt.Sprintf("pod-%d", i), Namespace: "ns", From 6a28f1995a4d0749d4871f80c0d8e2989e833a78 Mon Sep 17 00:00:00 2001 From: Gaurav Singh Date: Tue, 19 May 2020 16:42:20 -0400 Subject: [PATCH 3/3] Code review changes Signed-off-by: Gaurav Singh --- .../apiserver/pkg/storage/cacher/cacher_whitebox_test.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher_whitebox_test.go b/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher_whitebox_test.go index a8fc0670823..e8b75048982 100644 --- a/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher_whitebox_test.go +++ b/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher_whitebox_test.go @@ -680,9 +680,8 @@ func testCacherSendBookmarkEvents(t *testing.T, allowWatchBookmarks, expectedBoo resourceVersion := uint64(1000) go func() { deadline := time.Now().Add(time.Second) - var err error for i := 0; time.Now().Before(deadline); i++ { - err = cacher.watchCache.Add(&examplev1.Pod{ + err := cacher.watchCache.Add(&examplev1.Pod{ ObjectMeta: metav1.ObjectMeta{ Name: fmt.Sprintf("pod-%d", i), Namespace: "ns",