diff --git a/operators/multiclusterobservability/controllers/placementrule/manifestwork.go b/operators/multiclusterobservability/controllers/placementrule/manifestwork.go index 434a610e7..51040e785 100644 --- a/operators/multiclusterobservability/controllers/placementrule/manifestwork.go +++ b/operators/multiclusterobservability/controllers/placementrule/manifestwork.go @@ -983,28 +983,28 @@ func getObservabilityAddon(c client.Client, namespace string, found.Annotations = make(map[string]string) } - if _, ok := found.Annotations["observability.open-cluster-management.io/addon-source"]; !ok { - found.Annotations["observability.open-cluster-management.io/addon-source"] = "mco" + if _, ok := found.Annotations[addonSourceAnnotation]; !ok { + found.Annotations[addonSourceAnnotation] = "mco" } - if found.Annotations["observability.open-cluster-management.io/addon-source"] == "mco" { + if found.Annotations[addonSourceAnnotation] == "mco" { addon.Spec.EnableMetrics = mco.Spec.ObservabilityAddonSpec.EnableMetrics addon.Spec.Interval = mco.Spec.ObservabilityAddonSpec.Interval addon.Spec.ScrapeSizeLimitBytes = mco.Spec.ObservabilityAddonSpec.ScrapeSizeLimitBytes addon.Spec.Workers = mco.Spec.ObservabilityAddonSpec.Workers addon.Spec.Resources = config.GetOBAResources(mco.Spec.ObservabilityAddonSpec, mco.Spec.InstanceSize) - addon.Annotations["observability.open-cluster-management.io/addon-source"] = "mco" + addon.Annotations[addonSourceAnnotation] = "mco" } - if found.Annotations["observability.open-cluster-management.io/addon-source"] == "override" { + if found.Annotations[addonSourceAnnotation] == "override" { addon.Spec.EnableMetrics = found.Spec.EnableMetrics addon.Spec.Interval = found.Spec.Interval addon.Spec.ScrapeSizeLimitBytes = found.Spec.ScrapeSizeLimitBytes addon.Spec.Workers = found.Spec.Workers addon.Spec.Resources = found.Spec.Resources - addon.Annotations["observability.open-cluster-management.io/addon-source"] = "override" + addon.Annotations[addonSourceAnnotation] = "override" } return addon, nil diff --git a/operators/multiclusterobservability/controllers/placementrule/manifestwork_test.go b/operators/multiclusterobservability/controllers/placementrule/manifestwork_test.go index eb419e448..1ec14a578 100644 --- a/operators/multiclusterobservability/controllers/placementrule/manifestwork_test.go +++ b/operators/multiclusterobservability/controllers/placementrule/manifestwork_test.go @@ -33,7 +33,7 @@ import ( const ( pullSecretName = "test-pull-secret" - workSize = 13 + workSize = 14 ) func init() { diff --git a/operators/multiclusterobservability/controllers/placementrule/obsaddon.go b/operators/multiclusterobservability/controllers/placementrule/obsaddon.go index 2b5a1d299..0af345ca8 100644 --- a/operators/multiclusterobservability/controllers/placementrule/obsaddon.go +++ b/operators/multiclusterobservability/controllers/placementrule/obsaddon.go @@ -22,8 +22,9 @@ import ( ) const ( - obsAddonName = "observability-addon" - obsAddonFinalizer = "observability.open-cluster-management.io/addon-cleanup" + obsAddonName = "observability-addon" + obsAddonFinalizer = "observability.open-cluster-management.io/addon-cleanup" + addonSourceAnnotation = "observability.open-cluster-management.io/addon-source" ) func deleteObsAddon(c client.Client, namespace string) error { @@ -75,7 +76,7 @@ func createObsAddon(mco *mcov1beta2.MultiClusterObservability, c client.Client, Name: obsAddonName, Namespace: namespace, Annotations: map[string]string{ - "observability.open-cluster-management.io/addon-source": "mco", + addonSourceAnnotation: "mco", }, Labels: map[string]string{ ownerLabelKey: ownerLabelValue, @@ -112,7 +113,7 @@ func createObsAddon(mco *mcov1beta2.MultiClusterObservability, c client.Client, } // Check if existing addon was created by MCO - if found.Annotations != nil && found.Annotations["observability.open-cluster-management.io/addon-source"] == "mco" { + if found.Annotations != nil && found.Annotations[addonSourceAnnotation] == "mco" { // Only update if specs are different if found.Spec != ec.Spec { found.Spec = ec.Spec