Skip to content

Commit

Permalink
Merge pull request kubewharf#180 from mrlihanbo/bugfix/map-data-race
Browse files Browse the repository at this point in the history
  • Loading branch information
gary-lgy authored Jul 25, 2023
2 parents 080b7f4 + ca228b4 commit 4d336f8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pkg/controllers/follower/bidirectional_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]) {
Expand Down
12 changes: 7 additions & 5 deletions pkg/controllers/status/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4d336f8

Please sign in to comment.