diff --git a/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/types.go b/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/types.go index d277d7ca250..2ddb0667c4b 100644 --- a/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/types.go +++ b/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/types.go @@ -351,9 +351,6 @@ type ListOptions struct { // If this is not a watch, this field is ignored. // If the feature gate WatchBookmarks is not enabled in apiserver, // this field is ignored. - // - // This field is beta. - // // +optional AllowWatchBookmarks bool `json:"allowWatchBookmarks,omitempty" protobuf:"varint,9,opt,name=allowWatchBookmarks"` diff --git a/staging/src/k8s.io/apiserver/pkg/features/kube_features.go b/staging/src/k8s.io/apiserver/pkg/features/kube_features.go index bc23ed1a0e1..e1505c7b5a7 100644 --- a/staging/src/k8s.io/apiserver/pkg/features/kube_features.go +++ b/staging/src/k8s.io/apiserver/pkg/features/kube_features.go @@ -123,6 +123,7 @@ const ( // owner: @wojtek-t // alpha: v1.15 // beta: v1.16 + // GA: v1.17 // // Enables support for watch bookmark events. WatchBookmark featuregate.Feature = "WatchBookmark" @@ -161,7 +162,7 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS StorageVersionHash: {Default: true, PreRelease: featuregate.Beta}, WinOverlay: {Default: false, PreRelease: featuregate.Alpha}, WinDSR: {Default: false, PreRelease: featuregate.Alpha}, - WatchBookmark: {Default: true, PreRelease: featuregate.Beta}, + WatchBookmark: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, RequestManagement: {Default: false, PreRelease: featuregate.Alpha}, RemoveSelfLink: {Default: false, PreRelease: featuregate.Alpha}, } diff --git a/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go b/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go index 696999bf902..59dfe8057b0 100644 --- a/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go +++ b/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go @@ -301,8 +301,6 @@ type Cacher struct { watchersToStop []*cacheWatcher // Maintain a timeout queue to send the bookmark event before the watcher times out. bookmarkWatchers *watcherBookmarkTimeBuckets - // watchBookmark feature-gate - watchBookmarkEnabled bool } // NewCacherFromConfig creates a new Cacher responsible for servicing WATCH and LIST requests from @@ -355,11 +353,10 @@ func NewCacherFromConfig(config Config) (*Cacher, error) { // - reflector.ListAndWatch // and there are no guarantees on the order that they will stop. // So we will be simply closing the channel, and synchronizing on the WaitGroup. - stopCh: stopCh, - clock: clock, - timer: time.NewTimer(time.Duration(0)), - bookmarkWatchers: newTimeBucketWatchers(clock), - watchBookmarkEnabled: utilfeature.DefaultFeatureGate.Enabled(features.WatchBookmark), + stopCh: stopCh, + clock: clock, + timer: time.NewTimer(time.Duration(0)), + bookmarkWatchers: newTimeBucketWatchers(clock), } // Ensure that timer is stopped. @@ -516,8 +513,8 @@ func (c *Cacher) Watch(ctx context.Context, key string, resourceVersion string, watcher.forget = forgetWatcher(c, c.watcherIdx, triggerValue, triggerSupported) c.watchers.addWatcher(watcher, c.watcherIdx, triggerValue, triggerSupported) - // Add it to the queue only when server and client support watch bookmarks. - if c.watchBookmarkEnabled && watcher.allowWatchBookmarks { + // Add it to the queue only when the client support watch bookmarks. + if watcher.allowWatchBookmarks { c.bookmarkWatchers.addWatcher(watcher) } c.watcherIdx++ @@ -790,10 +787,6 @@ func (c *Cacher) processEvent(event *watchCacheEvent) { func (c *Cacher) dispatchEvents() { // Jitter to help level out any aggregate load. bookmarkTimer := c.clock.NewTimer(wait.Jitter(time.Second, 0.25)) - // Stop the timer when watchBookmarkFeatureGate is not enabled. - if !c.watchBookmarkEnabled && !bookmarkTimer.Stop() { - <-bookmarkTimer.C() - } defer bookmarkTimer.Stop() lastProcessedResourceVersion := uint64(0) 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 e73e81ce080..31984b9bc2e 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 @@ -658,8 +658,7 @@ func TestCacherNoLeakWithMultipleWatchers(t *testing.T) { } } -func testCacherSendBookmarkEvents(t *testing.T, watchCacheEnabled, allowWatchBookmarks, expectedBookmarks bool) { - defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.WatchBookmark, watchCacheEnabled)() +func testCacherSendBookmarkEvents(t *testing.T, allowWatchBookmarks, expectedBookmarks bool) { backingStorage := &dummyStorage{} cacher, _, err := newTestCacher(backingStorage, 1000) if err != nil { @@ -729,34 +728,21 @@ func testCacherSendBookmarkEvents(t *testing.T, watchCacheEnabled, allowWatchBoo func TestCacherSendBookmarkEvents(t *testing.T) { testCases := []struct { - watchCacheEnabled bool allowWatchBookmarks bool expectedBookmarks bool }{ { - watchCacheEnabled: true, allowWatchBookmarks: true, expectedBookmarks: true, }, { - watchCacheEnabled: true, - allowWatchBookmarks: false, - expectedBookmarks: false, - }, - { - watchCacheEnabled: false, - allowWatchBookmarks: true, - expectedBookmarks: false, - }, - { - watchCacheEnabled: false, allowWatchBookmarks: false, expectedBookmarks: false, }, } for _, tc := range testCases { - testCacherSendBookmarkEvents(t, tc.watchCacheEnabled, tc.allowWatchBookmarks, tc.expectedBookmarks) + testCacherSendBookmarkEvents(t, tc.allowWatchBookmarks, tc.expectedBookmarks) } }