@@ -109,14 +109,23 @@ func (r *ArgoCDMetricsReconciler) Reconcile(ctx context.Context, request reconci
109109 }
110110
111111 const clusterMonitoringLabel = "openshift.io/cluster-monitoring"
112- labelVal , exists := namespace .Labels [clusterMonitoringLabel ]
112+ const userDefinedMonitoringLabel = "openshift.io/user-monitoring"
113+ var labelVal , monitoringLabel string
114+ var exists bool
115+ if strings .HasPrefix (namespace .Name , "openshift-" ) {
116+ labelVal , exists = namespace .Labels [clusterMonitoringLabel ]
117+ monitoringLabel = clusterMonitoringLabel
118+ } else {
119+ labelVal , exists = namespace .Labels [userDefinedMonitoringLabel ]
120+ monitoringLabel = userDefinedMonitoringLabel
121+ }
113122
114123 if argocd .Spec .Monitoring .DisableMetrics == nil || ! * argocd .Spec .Monitoring .DisableMetrics {
115124 if ! exists || labelVal != "true" {
116125 if namespace .Labels == nil {
117126 namespace .Labels = make (map [string ]string )
118127 }
119- namespace .Labels [clusterMonitoringLabel ] = "true"
128+ namespace .Labels [monitoringLabel ] = "true"
120129 err = r .Client .Update (ctx , & namespace )
121130 if err != nil {
122131 reqLogger .Error (err , "Error updating namespace" ,
@@ -178,7 +187,7 @@ func (r *ArgoCDMetricsReconciler) Reconcile(ctx context.Context, request reconci
178187 }
179188 } else {
180189 if exists {
181- namespace .Labels [clusterMonitoringLabel ] = "false"
190+ namespace .Labels [monitoringLabel ] = "false"
182191 err = r .Client .Update (ctx , & namespace )
183192 if err != nil {
184193 reqLogger .Error (err , "Error updating namespace" ,
0 commit comments