Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[branch/v7] Remove refetching from resourceWatcher (#14262) #14307

Merged
merged 1 commit into from
Jul 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 2 additions & 18 deletions lib/services/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ type ResourceWatcherConfig struct {
Log logrus.FieldLogger
// MaxRetryPeriod is the maximum retry period on failed watchers.
MaxRetryPeriod time.Duration
// RefetchPeriod is a period after which to explicitly refetch the resources.
// It is to protect against unexpected cache syncing issues.
RefetchPeriod time.Duration
// Clock is used to control time.
Clock clockwork.Clock
// Client is used to create new watchers.
Expand All @@ -80,9 +77,6 @@ func (cfg *ResourceWatcherConfig) CheckAndSetDefaults() error {
if cfg.MaxRetryPeriod == 0 {
cfg.MaxRetryPeriod = defaults.MaxWatcherBackoff
}
if cfg.RefetchPeriod == 0 {
cfg.RefetchPeriod = defaults.LowResPollingPeriod
}
if cfg.Clock == nil {
cfg.Clock = clockwork.NewRealClock()
}
Expand Down Expand Up @@ -217,10 +211,7 @@ func (p *resourceWatcher) runWatchLoop() {
}
if err != nil {
p.Log.Warningf("Restart watch on error: %v.", err)
} else {
p.Log.Debug("Triggering scheduled refetch.")
}

}
}

Expand All @@ -236,7 +227,6 @@ func (p *resourceWatcher) watch() error {
return trace.Wrap(err)
}
defer watcher.Close()
refetchC := time.After(p.RefetchPeriod)

// before fetch, make sure watcher is synced by receiving init event,
// to avoid the scenario:
Expand All @@ -254,10 +244,7 @@ func (p *resourceWatcher) watch() error {
// by receiving init event first.
select {
case <-watcher.Done():
return trace.ConnectionProblem(watcher.Error(), "watcher is closed")
case <-refetchC:
p.Log.Debug("Triggering scheduled refetch.")
return nil
return trace.ConnectionProblem(watcher.Error(), "watcher is closed: %v", watcher.Error())
case <-p.ctx.Done():
return trace.ConnectionProblem(p.ctx.Err(), "context is closing")
case event := <-watcher.Events():
Expand All @@ -275,10 +262,7 @@ func (p *resourceWatcher) watch() error {
for {
select {
case <-watcher.Done():
return trace.ConnectionProblem(watcher.Error(), "watcher is closed")
case <-refetchC:
p.Log.Debug("Triggering scheduled refetch.")
return nil
return trace.ConnectionProblem(watcher.Error(), "watcher is closed: %v", watcher.Error())
case <-p.ctx.Done():
return trace.ConnectionProblem(p.ctx.Err(), "context is closing")
case event := <-watcher.Events():
Expand Down