From a08d1b5f3286c6f3698abf59022055dc0b4b922f Mon Sep 17 00:00:00 2001 From: Marek Siarkowicz Date: Tue, 23 Apr 2024 12:27:03 +0200 Subject: [PATCH] Remove workarounds for https://github.com/etcd-io/etcd/issues/17507 --- .../apiserver/pkg/storage/cacher/cacher_test.go | 17 ----------------- .../pkg/storage/cacher/cacher_whitebox_test.go | 9 ++++----- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher_test.go b/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher_test.go index 01995b1b1b6..92e31421bcc 100644 --- a/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher_test.go +++ b/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher_test.go @@ -177,13 +177,6 @@ func TestListWithConsistentListFromCache(t *testing.T) { defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.ConsistentListFromCache, true)() ctx, cacher, server, terminate := testSetupWithEtcdServer(t) t.Cleanup(terminate) - // Wait before sending watch progress request to avoid https://github.com/etcd-io/etcd/issues/17507 - // TODO(https://github.com/etcd-io/etcd/issues/17507): Remove the wait when etcd is upgraded to version with fix. - err := cacher.ready.wait(ctx) - if err != nil { - t.Fatal(err) - } - time.Sleep(time.Second) storagetesting.RunTestList(ctx, t, cacher, compactStorage(cacher, server.V3Client), true) } @@ -198,13 +191,6 @@ func TestConsistentListWithConsistentListFromCache(t *testing.T) { defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.ConsistentListFromCache, true)() ctx, cacher, server, terminate := testSetupWithEtcdServer(t) t.Cleanup(terminate) - // Wait before sending watch progress request to avoid https://github.com/etcd-io/etcd/issues/17507 - // TODO(https://github.com/etcd-io/etcd/issues/17507): Remove the wait when etcd is upgraded to version with fix. - err := cacher.ready.wait(ctx) - if err != nil { - t.Fatal(err) - } - time.Sleep(time.Second) storagetesting.RunTestConsistentList(ctx, t, cacher, compactStorage(cacher, server.V3Client), true, true) } @@ -219,9 +205,6 @@ func TestGetListNonRecursiveWithConsistentListFromCache(t *testing.T) { defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.ConsistentListFromCache, true)() ctx, cacher, server, terminate := testSetupWithEtcdServer(t) t.Cleanup(terminate) - // Wait before sending watch progress request to avoid https://github.com/etcd-io/etcd/issues/17507 - // TODO(https://github.com/etcd-io/etcd/issues/17507): Remove sleep when etcd is upgraded to version with fix. - time.Sleep(time.Second) storagetesting.RunTestGetListNonRecursive(ctx, t, compactStorage(cacher, server.V3Client), cacher) } 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 46990991310..f73c146de53 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 @@ -2446,9 +2446,8 @@ func TestWatchStreamSeparation(t *testing.T) { if tc.useWatchCacheContextMetadata { contextMetadata = cacher.watchCache.waitingUntilFresh.contextMetadata } - // Wait before sending watch progress request to avoid https://github.com/etcd-io/etcd/issues/17507 - // TODO(https://github.com/etcd-io/etcd/issues/17507): Remove sleep when etcd is upgraded to version with fix. - time.Sleep(time.Second) + // For the first 100ms from watch creation, watch progress requests are ignored. + time.Sleep(200 * time.Millisecond) err = cacher.storage.RequestWatchProgress(metadata.NewOutgoingContext(context.Background(), contextMetadata)) if err != nil { t.Fatal(err) @@ -2459,13 +2458,13 @@ func TestWatchStreamSeparation(t *testing.T) { etcdWatchResourceVersion := waitForEtcdBookmark() gotEtcdWatchBookmark := etcdWatchResourceVersion == lastResourceVersion if gotEtcdWatchBookmark != tc.expectBookmarkOnEtcd { - t.Errorf("Unexpected etcd bookmark check result, rv: %d, got: %v, want: %v", etcdWatchResourceVersion, etcdWatchResourceVersion, tc.expectBookmarkOnEtcd) + t.Errorf("Unexpected etcd bookmark check result, rv: %d, lastRV: %d, wantMatching: %v", etcdWatchResourceVersion, lastResourceVersion, tc.expectBookmarkOnEtcd) } watchCacheResourceVersion := getCacherRV() cacherGotBookmark := watchCacheResourceVersion == lastResourceVersion if cacherGotBookmark != tc.expectBookmarkOnWatchCache { - t.Errorf("Unexpected watch cache bookmark check result, rv: %d, got: %v, want: %v", watchCacheResourceVersion, cacherGotBookmark, tc.expectBookmarkOnWatchCache) + t.Errorf("Unexpected watch cache bookmark check result, rv: %d, lastRV: %d, wantMatching: %v", watchCacheResourceVersion, lastResourceVersion, tc.expectBookmarkOnWatchCache) } }) }