diff --git a/pkg/controllers/follower/bidirectional_cache.go b/pkg/controllers/follower/bidirectional_cache.go index 394b8576..8935eb5d 100644 --- a/pkg/controllers/follower/bidirectional_cache.go +++ b/pkg/controllers/follower/bidirectional_cache.go @@ -39,13 +39,13 @@ type bidirectionalCache[V1, V2 comparable] struct { func (c *bidirectionalCache[V1, V2]) lookup(key V1) sets.Set[V2] { c.RLock() defer c.RUnlock() - return c.cache[key] + return c.cache[key].Clone() } func (c *bidirectionalCache[V1, V2]) reverseLookup(key V2) sets.Set[V1] { c.RLock() defer c.RUnlock() - return c.reverseCache[key] + return c.reverseCache[key].Clone() } func (c *bidirectionalCache[V1, V2]) update(key V1, newValues sets.Set[V2]) { diff --git a/pkg/controllers/status/controller.go b/pkg/controllers/status/controller.go index 51c9c464..e33d9e40 100644 --- a/pkg/controllers/status/controller.go +++ b/pkg/controllers/status/controller.go @@ -560,11 +560,13 @@ func (s *StatusController) clusterStatuses( clusterStatus = append(clusterStatus, resourceClusterStatus) } - s.eventRecorder.Eventf( - fedObject, - corev1.EventTypeWarning, EventReasonGetObjectStatusError, - fmt.Sprintf("Failed to get some cluster status, error info: %s", strings.Join(errList, ". ")), - ) + if len(errList) != 0 { + s.eventRecorder.Eventf( + fedObject, + corev1.EventTypeWarning, EventReasonGetObjectStatusError, + fmt.Sprintf("Failed to get some cluster status, error info: %s", strings.Join(errList, ". ")), + ) + } sort.Slice(clusterStatus, func(i, j int) bool { return clusterStatus[i].ClusterName < clusterStatus[j].ClusterName