Skip to content

Commit

Permalink
Allow for bad revision on empty list.
Browse files Browse the repository at this point in the history
Looks like k8s might return that in some cases (customK8sResourceClient
checks for it).
  • Loading branch information
fasaxc committed Dec 19, 2024
1 parent dda0f92 commit e193b8c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion libcalico-go/lib/backend/watchersyncer/watchercache.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,17 @@ func (wc *watcherCache) resyncAndCreateWatcher(ctx context.Context) {
// Store the current watch revision. This gets updated on any new add/modified event.
wc.logger.Logger.WithField("revision", l.Revision).Debug("List completed.")
if l.Revision == "" || l.Revision == "0" {
wc.logger.Panic("BUG: List returned empty/zero revision. Watch would be inconsistent.")
if len(l.KVPairs) == 0 {
// Got a bad revision but there are no items. This may mean that the datastore
// returns an unhelpful "not found" error instead of an empty list. Revert to a
// poll until some items show up.
wc.logger.Info("List returned no items and an empty/zero revision, reverting to poll.")
wc.currentWatchRevision = "0"
performFullResync = true
wc.resyncBlockedUntil = time.Now().Add(WatchPollInterval)
continue
}
wc.logger.Panic("BUG: List returned items with empty/zero revision. Watch would be inconsistent.")
}
wc.currentWatchRevision = l.Revision

Expand Down

0 comments on commit e193b8c

Please sign in to comment.