Skip to content
This repository has been archived by the owner on Sep 19, 2022. It is now read-only.

Commit

Permalink
> fix watcher stop error
Browse files Browse the repository at this point in the history
  • Loading branch information
kebe7jun committed Apr 21, 2022
1 parent 4347cbc commit 4ebffe1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions watcher/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ func (w *watcher) watchResources(r store.GroupVersionResource, cluster string) {
config.NegotiatedSerializer = scheme.Codecs.WithoutConversion()
rt, _ := rest.RESTClientFor(&config)
for {
select {
case <-w.stop:
return
default:
}
ctx, calcel := context.WithTimeout(context.Background(), time.Hour)
url := ""
if r.Group == "" {
Expand All @@ -146,7 +151,7 @@ func (w *watcher) watchResources(r store.GroupVersionResource, cluster string) {
ww, err := rt.Get().RequestURI(url).Timeout(time.Hour).Watch(ctx)
if err != nil {
log.Errorf("cluster(%s): create watcher for %s error: %v", cluster, url, err)
time.Sleep(time.Second * 3)
time.Sleep(time.Second * 15)
} else {
resultChan:
for {
Expand Down Expand Up @@ -177,7 +182,7 @@ func (w *watcher) watchResources(r store.GroupVersionResource, cluster string) {
}
case <-w.stop:
ww.Stop()
break resultChan
return
}
}
}
Expand Down

0 comments on commit 4ebffe1

Please sign in to comment.