Skip to content

Commit

Permalink
fix concurrent map writes
Browse files Browse the repository at this point in the history
Signed-off-by: Coleen Iona Quadros <[email protected]>
  • Loading branch information
coleenquadros committed Sep 30, 2024
1 parent bba8b83 commit 1e1e584
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,6 @@ func (r *PlacementRuleReconciler) Reconcile(ctx context.Context, req ctrl.Reques
return ctrl.Result{}, err
}
}
if operatorconfig.IsMCOTerminating {
delete(managedClusterList, "local-cluster")
}

if !deleteAll {
if err := createAllRelatedRes(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (
"reflect"
"strings"

clusterv1 "open-cluster-management.io/api/cluster/v1"

"github.com/stolostron/multicluster-observability-operator/operators/multiclusterobservability/pkg/config"
operatorconfig "github.com/stolostron/multicluster-observability-operator/operators/pkg/config"

Expand All @@ -26,20 +24,16 @@ func getClusterPreds() predicate.Funcs {
createFunc := func(e event.CreateEvent) bool {
log.Info("CreateFunc", "managedCluster", e.Object.GetName())

//ACM 8509: Special case for local-cluster, we do not react changes to
//local-cluster as it is expected to be always present in the managed cluster list
//whether hubSelfManagement is enabled or not
if e.Object.GetName() == "local-cluster" {
return false
}

if isAutomaticAddonInstallationDisabled(e.Object) {
return false
}
updateManagedClusterImageRegistry(e.Object)
if !areManagedClusterLabelsReady(e.Object) {
return false
}
//ACM 8509: Special case for local-cluster, we do not react changes to
//local-cluster as it is expected to be always present in the managed cluster list
//whether hubSelfManagement is enabled or not
if e.Object.GetName() != localClusterName {
updateManagedClusterList(e.Object)
}
Expand All @@ -50,10 +44,6 @@ func getClusterPreds() predicate.Funcs {
updateFunc := func(e event.UpdateEvent) bool {
log.Info("UpdateFunc", "managedCluster", e.ObjectNew.GetName())

if e.ObjectNew.GetName() == "local-cluster" {
return false
}

if e.ObjectNew.GetResourceVersion() == e.ObjectOld.GetResourceVersion() {
return false
}
Expand All @@ -72,31 +62,28 @@ func getClusterPreds() predicate.Funcs {
if !areManagedClusterLabelsReady(e.ObjectNew) {
return false
}
//ACM 8509: Special case for local-cluster, we do not react changes to
//local-cluster as it is expected to be always present in the managed cluster list
//whether hubSelfManagement is enabled or not
if e.ObjectNew.GetName() != localClusterName {
updateManagedClusterList(e.ObjectNew)
}

}
//log the diff in managedccluster object
if !reflect.DeepEqual(e.ObjectNew.(*clusterv1.ManagedCluster), e.ObjectOld.(*clusterv1.ManagedCluster)) {
log.Info("managedcluster object New diff", "managedCluster", e.ObjectNew.GetName(), "diff", fmt.Sprintf("%+v", e.ObjectNew.(*clusterv1.ManagedCluster)))
log.Info("managedcluster object Old diff", "managedCluster", e.ObjectOld.GetName(), "diff", fmt.Sprintf("%+v", e.ObjectOld.(*clusterv1.ManagedCluster)))
}

return true
}

deleteFunc := func(e event.DeleteEvent) bool {
log.Info("DeleteFunc", "managedCluster", e.Object.GetName())

if e.Object.GetName() == "local-cluster" {
return false
}

if isAutomaticAddonInstallationDisabled(e.Object) {
return false
}

//ACM 8509: Special case for local-cluster, we do not react changes to
//local-cluster as it is expected to be always present in the managed cluster list
//whether hubSelfManagement is enabled or not
if e.Object.GetName() != localClusterName {
managedClusterList.Delete(e.Object.GetName())
}
Expand Down

0 comments on commit 1e1e584

Please sign in to comment.