Skip to content

Commit 065bf20

Browse files
committed
Deprecate WatchFromStorageWithoutResourceVersion
Around the 1.31 release, we discovered that a change introduced in 1.27 allowead clients to open WATCH requests directly to etcd. This had detrimental consequences, enabling abusive clients to bypass caching and overwhelm etcd. Unlike the API server, etcd lacks protection against such behavior. To mitigate this, we redirected all WATCH requests to be served from the cache. The WatchFromStorageWithoutResourceVersion feature gate was retained as an escape hatch. However, since we have no plans to allow direct WATCH requests to etcd again, this flag is now obsolete. Direct WATCH requests to etcd offer no advantage, as they don't provide stronger consistency guarantees. WATCH operations are inherently inconsistent; unlike LIST operations, they do not confirm the resource version with a quorum. While Kubernetes uses the WithRequireLeader option on WATCH requests to prevent maintaining connections to isolated etcd members, the API server provides the same level of guarantee through its health checks, which fail if it cannot connect to etcd member. Therefore, the WatchFromStorageWithoutResourceVersion feature gate can be deprecated and removed.
1 parent 3bc8f01 commit 065bf20

File tree

4 files changed

+7
-21
lines changed

4 files changed

+7
-21
lines changed

pkg/features/versioned_kube_features.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ var defaultVersionedKubernetesFeatureGates = map[featuregate.Feature]featuregate
368368

369369
genericfeatures.WatchFromStorageWithoutResourceVersion: {
370370
{Version: version.MustParse("1.27"), Default: false, PreRelease: featuregate.Beta},
371+
{Version: version.MustParse("1.33"), Default: false, PreRelease: featuregate.Deprecated, LockToDefault: true},
371372
},
372373

373374
genericfeatures.WatchList: {

staging/src/k8s.io/apiserver/pkg/features/kube_features.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ var defaultVersionedKubernetesFeatureGates = map[featuregate.Feature]featuregate
407407

408408
WatchFromStorageWithoutResourceVersion: {
409409
{Version: version.MustParse("1.27"), Default: false, PreRelease: featuregate.Beta},
410+
{Version: version.MustParse("1.33"), Default: false, PreRelease: featuregate.Deprecated, LockToDefault: true},
410411
},
411412

412413
WatchList: {

staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher_whitebox_test.go

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -594,27 +594,7 @@ func TestWatchCacheBypass(t *testing.T) {
594594
Predicate: storage.Everything,
595595
})
596596
if err != nil {
597-
t.Errorf("Watch with RV=0 should be served from cache: %v", err)
598-
}
599-
600-
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.WatchFromStorageWithoutResourceVersion, false)
601-
_, err = proxy.Watch(context.TODO(), "pod/ns", storage.ListOptions{
602-
ResourceVersion: "",
603-
Predicate: storage.Everything,
604-
})
605-
if err != nil {
606-
t.Errorf("With WatchFromStorageWithoutResourceVersion disabled, watch with unset RV should be served from cache: %v", err)
607-
}
608-
609-
// Inject error to underlying layer and check if cacher is not bypassed.
610-
backingStorage.injectError(errDummy)
611-
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.WatchFromStorageWithoutResourceVersion, true)
612-
_, err = proxy.Watch(context.TODO(), "pod/ns", storage.ListOptions{
613-
ResourceVersion: "",
614-
Predicate: storage.Everything,
615-
})
616-
if !errors.Is(err, errDummy) {
617-
t.Errorf("With WatchFromStorageWithoutResourceVersion enabled, watch with unset RV should be served from storage: %v", err)
597+
t.Errorf("Watch without RV=0 should be served from cache: %v", err)
618598
}
619599
}
620600

test/featuregates_linter/test_data/versioned_feature_list.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,6 +1478,10 @@
14781478
lockToDefault: false
14791479
preRelease: Beta
14801480
version: "1.27"
1481+
- default: false
1482+
lockToDefault: true
1483+
preRelease: Deprecated
1484+
version: "1.33"
14811485
- name: WatchList
14821486
versionedSpecs:
14831487
- default: false

0 commit comments

Comments
 (0)