stop proxy cache asynchronously

Signed-off-by: yingjinhui <yingjinhui@didiglobal.com>
This commit is contained in:
yingjinhui 2023-01-06 17:57:42 +08:00
parent 0330535ed8
commit ce158ec243
2 changed files with 9 additions and 1 deletions

View File

@ -7,6 +7,7 @@ import (
"sort"
"strings"
"sync"
"time"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
@ -57,6 +58,13 @@ func NewMultiClusterCache(newClientFunc func(string) (dynamic.Interface, error),
// UpdateCache update cache for multi clusters
func (c *MultiClusterCache) UpdateCache(resourcesByCluster map[string]map[schema.GroupVersionResource]struct{}) error {
if klog.V(3).Enabled() {
start := time.Now()
defer func() {
klog.Infof("MultiClusterCache update cache takes %v", time.Since(start))
}()
}
c.lock.Lock()
defer c.lock.Unlock()

View File

@ -33,7 +33,7 @@ type resourceCache struct {
func (c *resourceCache) stop() {
klog.Infof("Stop store for %s %s", c.clusterName, c.resource)
c.Store.DestroyFunc()
go c.Store.DestroyFunc()
}
func newResourceCache(clusterName string, gvr schema.GroupVersionResource, gvk schema.GroupVersionKind,