Skip to content

Commit

Permalink
Merge pull request #3388 from niuyueyang1996/automated-cherry-pick-of…
Browse files Browse the repository at this point in the history
…-#3376-upstream-release-1.4

Automated cherry pick of #3376: if start many watcher to watch pod. pod resourceVersion will
  • Loading branch information
karmada-bot committed Apr 12, 2023
2 parents 2006573 + d662269 commit 6824165
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
1 change: 0 additions & 1 deletion pkg/search/proxy/store/multi_cluster_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,6 @@ func (c *MultiClusterCache) Watch(ctx context.Context, gvr schema.GroupVersionRe
}

mux.AddSource(w, func(e watch.Event) {
// We can safely modify data because it is deepCopied in cacheWatcher.convertToWatchEvent
setObjectResourceVersionFunc(cluster, e.Object)
addCacheSourceAnnotation(e.Object, cluster)
})
Expand Down
11 changes: 6 additions & 5 deletions pkg/search/proxy/store/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,15 +214,16 @@ func (w *watchMux) startWatchSource(source watch.Interface, decorator func(watch
defer source.Stop()
defer w.Stop()
for {
var event watch.Event
var ok bool
var copyEvent watch.Event
select {
case event, ok = <-source.ResultChan():
case sourceEvent, ok := <-source.ResultChan():
if !ok {
return
}
// sourceEvent object is cacheObject,all watcher use the same point,must deepcopy.
copyEvent = *sourceEvent.DeepCopy()
if decorator != nil {
decorator(event)
decorator(copyEvent)
}
case <-w.done:
return
Expand All @@ -241,7 +242,7 @@ func (w *watchMux) startWatchSource(source watch.Interface, decorator func(watch
case <-w.done:
return
default:
w.result <- event
w.result <- copyEvent
}
}()
}
Expand Down

0 comments on commit 6824165

Please sign in to comment.