@@ -109,14 +109,23 @@ func (r *ArgoCDMetricsReconciler) Reconcile(ctx context.Context, request reconci
109
109
}
110
110
111
111
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
+ }
113
122
114
123
if argocd .Spec .Monitoring .DisableMetrics == nil || ! * argocd .Spec .Monitoring .DisableMetrics {
115
124
if ! exists || labelVal != "true" {
116
125
if namespace .Labels == nil {
117
126
namespace .Labels = make (map [string ]string )
118
127
}
119
- namespace .Labels [clusterMonitoringLabel ] = "true"
128
+ namespace .Labels [monitoringLabel ] = "true"
120
129
err = r .Client .Update (ctx , & namespace )
121
130
if err != nil {
122
131
reqLogger .Error (err , "Error updating namespace" ,
@@ -178,7 +187,7 @@ func (r *ArgoCDMetricsReconciler) Reconcile(ctx context.Context, request reconci
178
187
}
179
188
} else {
180
189
if exists {
181
- namespace .Labels [clusterMonitoringLabel ] = "false"
190
+ namespace .Labels [monitoringLabel ] = "false"
182
191
err = r .Client .Update (ctx , & namespace )
183
192
if err != nil {
184
193
reqLogger .Error (err , "Error updating namespace" ,
0 commit comments