Promote WatchBookmarks feature to GA

This commit is contained in:
wojtekt 2019-09-26 15:29:52 +02:00
parent f64c631cd7
commit a22a4ed3c5
4 changed files with 10 additions and 33 deletions

View File

@ -351,9 +351,6 @@ type ListOptions struct {
// If this is not a watch, this field is ignored. // If this is not a watch, this field is ignored.
// If the feature gate WatchBookmarks is not enabled in apiserver, // If the feature gate WatchBookmarks is not enabled in apiserver,
// this field is ignored. // this field is ignored.
//
// This field is beta.
//
// +optional // +optional
AllowWatchBookmarks bool `json:"allowWatchBookmarks,omitempty" protobuf:"varint,9,opt,name=allowWatchBookmarks"` AllowWatchBookmarks bool `json:"allowWatchBookmarks,omitempty" protobuf:"varint,9,opt,name=allowWatchBookmarks"`

View File

@ -123,6 +123,7 @@ const (
// owner: @wojtek-t // owner: @wojtek-t
// alpha: v1.15 // alpha: v1.15
// beta: v1.16 // beta: v1.16
// GA: v1.17
// //
// Enables support for watch bookmark events. // Enables support for watch bookmark events.
WatchBookmark featuregate.Feature = "WatchBookmark" WatchBookmark featuregate.Feature = "WatchBookmark"
@ -161,7 +162,7 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS
StorageVersionHash: {Default: true, PreRelease: featuregate.Beta}, StorageVersionHash: {Default: true, PreRelease: featuregate.Beta},
WinOverlay: {Default: false, PreRelease: featuregate.Alpha}, WinOverlay: {Default: false, PreRelease: featuregate.Alpha},
WinDSR: {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}, RequestManagement: {Default: false, PreRelease: featuregate.Alpha},
RemoveSelfLink: {Default: false, PreRelease: featuregate.Alpha}, RemoveSelfLink: {Default: false, PreRelease: featuregate.Alpha},
} }

View File

@ -301,8 +301,6 @@ type Cacher struct {
watchersToStop []*cacheWatcher watchersToStop []*cacheWatcher
// Maintain a timeout queue to send the bookmark event before the watcher times out. // Maintain a timeout queue to send the bookmark event before the watcher times out.
bookmarkWatchers *watcherBookmarkTimeBuckets bookmarkWatchers *watcherBookmarkTimeBuckets
// watchBookmark feature-gate
watchBookmarkEnabled bool
} }
// NewCacherFromConfig creates a new Cacher responsible for servicing WATCH and LIST requests from // 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 // - reflector.ListAndWatch
// and there are no guarantees on the order that they will stop. // 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. // So we will be simply closing the channel, and synchronizing on the WaitGroup.
stopCh: stopCh, stopCh: stopCh,
clock: clock, clock: clock,
timer: time.NewTimer(time.Duration(0)), timer: time.NewTimer(time.Duration(0)),
bookmarkWatchers: newTimeBucketWatchers(clock), bookmarkWatchers: newTimeBucketWatchers(clock),
watchBookmarkEnabled: utilfeature.DefaultFeatureGate.Enabled(features.WatchBookmark),
} }
// Ensure that timer is stopped. // 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) watcher.forget = forgetWatcher(c, c.watcherIdx, triggerValue, triggerSupported)
c.watchers.addWatcher(watcher, 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. // Add it to the queue only when the client support watch bookmarks.
if c.watchBookmarkEnabled && watcher.allowWatchBookmarks { if watcher.allowWatchBookmarks {
c.bookmarkWatchers.addWatcher(watcher) c.bookmarkWatchers.addWatcher(watcher)
} }
c.watcherIdx++ c.watcherIdx++
@ -790,10 +787,6 @@ func (c *Cacher) processEvent(event *watchCacheEvent) {
func (c *Cacher) dispatchEvents() { func (c *Cacher) dispatchEvents() {
// Jitter to help level out any aggregate load. // Jitter to help level out any aggregate load.
bookmarkTimer := c.clock.NewTimer(wait.Jitter(time.Second, 0.25)) 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() defer bookmarkTimer.Stop()
lastProcessedResourceVersion := uint64(0) lastProcessedResourceVersion := uint64(0)

View File

@ -658,8 +658,7 @@ func TestCacherNoLeakWithMultipleWatchers(t *testing.T) {
} }
} }
func testCacherSendBookmarkEvents(t *testing.T, watchCacheEnabled, allowWatchBookmarks, expectedBookmarks bool) { func testCacherSendBookmarkEvents(t *testing.T, allowWatchBookmarks, expectedBookmarks bool) {
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.WatchBookmark, watchCacheEnabled)()
backingStorage := &dummyStorage{} backingStorage := &dummyStorage{}
cacher, _, err := newTestCacher(backingStorage, 1000) cacher, _, err := newTestCacher(backingStorage, 1000)
if err != nil { if err != nil {
@ -729,34 +728,21 @@ func testCacherSendBookmarkEvents(t *testing.T, watchCacheEnabled, allowWatchBoo
func TestCacherSendBookmarkEvents(t *testing.T) { func TestCacherSendBookmarkEvents(t *testing.T) {
testCases := []struct { testCases := []struct {
watchCacheEnabled bool
allowWatchBookmarks bool allowWatchBookmarks bool
expectedBookmarks bool expectedBookmarks bool
}{ }{
{ {
watchCacheEnabled: true,
allowWatchBookmarks: true, allowWatchBookmarks: true,
expectedBookmarks: true, expectedBookmarks: true,
}, },
{ {
watchCacheEnabled: true,
allowWatchBookmarks: false,
expectedBookmarks: false,
},
{
watchCacheEnabled: false,
allowWatchBookmarks: true,
expectedBookmarks: false,
},
{
watchCacheEnabled: false,
allowWatchBookmarks: false, allowWatchBookmarks: false,
expectedBookmarks: false, expectedBookmarks: false,
}, },
} }
for _, tc := range testCases { for _, tc := range testCases {
testCacherSendBookmarkEvents(t, tc.watchCacheEnabled, tc.allowWatchBookmarks, tc.expectedBookmarks) testCacherSendBookmarkEvents(t, tc.allowWatchBookmarks, tc.expectedBookmarks)
} }
} }