Skip to content

Commit

Permalink
refactor: cleanups (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
ash2k authored Oct 13, 2020
1 parent 54bbebf commit ef7702f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions pkg/cache/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,13 +442,17 @@ func (c *clusterCache) watchEvents(ctx context.Context, api kube.APIResourceInfo
return res, err
},
})
if err != nil {
return err
}

defer func() {
w.Stop()
resourceVersion = ""
}()

shouldResync := time.After(watchResyncTimeout)
shouldResync := time.NewTimer(watchResyncTimeout)
defer shouldResync.Stop()

for {
select {
Expand All @@ -457,7 +461,7 @@ func (c *clusterCache) watchEvents(ctx context.Context, api kube.APIResourceInfo
return nil

// re-synchronize API state and restart watch periodically
case <-shouldResync:
case <-shouldResync.C:
return fmt.Errorf("Resyncing %s on %s during to timeout", api.GroupKind, c.config.Host)

// re-synchronize API state and restart watch if retry watcher failed to continue watching using provided resource version
Expand Down Expand Up @@ -488,11 +492,11 @@ func (c *clusterCache) watchEvents(ctx context.Context, api kube.APIResourceInfo
err = runSynced(&c.lock, func() error {
return c.startMissingWatches()
})
if err != nil {
c.log.Warnf("Failed to start missing watch: %v", err)
}
}
}
if err != nil {
c.log.Warnf("Failed to start missing watch: %v", err)
}
}
}
})
Expand Down

0 comments on commit ef7702f

Please sign in to comment.