Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
fix: do not consider resource status when disabled (#7)
Browse files Browse the repository at this point in the history
* chore: preserve unknown fields

Signed-off-by: Hector Fernandez <[email protected]>

* Do not consider resource status when disabled

managedDispatcherImpl.RecordStatus only writes status if collection is enabled. Because of that if collection is disabled, resource map will always differ from the expected map of all clusters.

Signed-off-by: Alena Varkockova <[email protected]>

Co-authored-by: Hector Fernandez <[email protected]>
  • Loading branch information
alenkacz and Hector Fernandez authored Dec 8, 2020
1 parent 6c72bac commit 29eee26
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pkg/controller/sync/status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (s *GenericFederatedStatus) update(generation int64, reason AggregateReason
}
}

clustersChanged := s.setClusters(collectedStatus.StatusMap, collectedResourceStatus.StatusMap)
clustersChanged := s.setClusters(collectedStatus.StatusMap, collectedResourceStatus.StatusMap, resourceStatusCollection)

// Indicate that changes were propagated if either status.clusters
// was changed or if existing resources were updated (which could
Expand All @@ -196,8 +196,8 @@ func (s *GenericFederatedStatus) update(generation int64, reason AggregateReason
// setClusters sets the status.clusters slice from propagation and resource status
// maps. Returns a boolean indication of whether the status.clusters was
// modified.
func (s *GenericFederatedStatus) setClusters(statusMap PropagationStatusMap, resourceStatusMap map[string]interface{}) bool {
if !s.clustersDiffer(statusMap, resourceStatusMap) {
func (s *GenericFederatedStatus) setClusters(statusMap PropagationStatusMap, resourceStatusMap map[string]interface{}, resourceStatusCollection bool) bool {
if !s.clustersDiffer(statusMap, resourceStatusMap, resourceStatusCollection) {
return false
}
s.Clusters = []GenericClusterStatus{}
Expand All @@ -214,9 +214,9 @@ func (s *GenericFederatedStatus) setClusters(statusMap PropagationStatusMap, res

// clustersDiffer checks whether `status.clusters` differs from the
// given status map.
func (s *GenericFederatedStatus) clustersDiffer(statusMap PropagationStatusMap, resourceStatusMap map[string]interface{}) bool {
if len(s.Clusters) != len(statusMap) || len(s.Clusters) != len(resourceStatusMap) {
klog.Info("Clusters differs from the size")
func (s *GenericFederatedStatus) clustersDiffer(statusMap PropagationStatusMap, resourceStatusMap map[string]interface{}, resourceStatusCollection bool) bool {
if len(s.Clusters) != len(statusMap) || (resourceStatusCollection && len(s.Clusters) != len(resourceStatusMap)) {
klog.Infof("Clusters differs from the size: %v, status: %v, resourceStatus: %v", s.Clusters, statusMap, resourceStatusMap)
return true
}
for _, status := range s.Clusters {
Expand Down

0 comments on commit 29eee26

Please sign in to comment.