Skip to content

Commit

Permalink
Add annotation predicate, update in mco mode
Browse files Browse the repository at this point in the history
Signed-off-by: Saswata Mukherjee <[email protected]>
  • Loading branch information
saswatamcode committed Dec 11, 2024
1 parent a9665f9 commit 1e32f01
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,21 @@ func createObsAddon(mco *mcov1beta2.MultiClusterObservability, c client.Client,
return err
}

// Check if existing addon was created by MCO
if found.Annotations != nil && found.Annotations["observability.open-cluster-management.io/addon-source"] == "mco" {
// Only update if specs are different
if found.Spec != ec.Spec {
found.Spec = ec.Spec
err = c.Update(context.TODO(), found)
if err != nil {
log.Error(err, "Failed to update observabilityaddon cr")
return err
}
log.Info("observabilityaddon updated", "namespace", namespace)
return nil
}
}

log.Info("observabilityaddon already existed/unchanged", "namespace", namespace)
return nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,9 @@ func (r *PlacementRuleReconciler) SetupWithManager(mgr ctrl.Manager) error {
!reflect.DeepEqual(e.ObjectNew.(*mcov1beta1.ObservabilityAddon).Status.Conditions,
e.ObjectOld.(*mcov1beta1.ObservabilityAddon).Status.Conditions) &&
!reflect.DeepEqual(e.ObjectNew.(*mcov1beta1.ObservabilityAddon).Spec,
e.ObjectOld.(*mcov1beta1.ObservabilityAddon).Spec) {
e.ObjectOld.(*mcov1beta1.ObservabilityAddon).Spec) &&
!reflect.DeepEqual(e.ObjectNew.(*mcov1beta1.ObservabilityAddon).Annotations,
e.ObjectOld.(*mcov1beta1.ObservabilityAddon).Annotations) {
return true
}
return false
Expand Down

0 comments on commit 1e32f01

Please sign in to comment.