From d19162310d5e1d0035adda2eff07263452ab606f Mon Sep 17 00:00:00 2001 From: Tom Pantelis Date: Mon, 6 May 2024 17:05:16 -0400 Subject: [PATCH] Use correct request namespace when creating ServiceMonitors Use "openshiftMonitoringNS" instead of "ns" when first attempting to create in the former namespace. Signed-off-by: Tom Pantelis --- pkg/metrics/service-monitor.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/metrics/service-monitor.go b/pkg/metrics/service-monitor.go index 1576d6cef..c1260e904 100644 --- a/pkg/metrics/service-monitor.go +++ b/pkg/metrics/service-monitor.go @@ -62,7 +62,8 @@ func CreateServiceMonitors(ctx context.Context, config *rest.Config, ns string, // On OpenShift, we need to create the service monitors in the OpenShift monitoring namespace, not the // service's. If that namespace doesn't exist then create in the provided namespace. - smc, err := mclient.ServiceMonitors(ns).Create(ctx, GenerateServiceMonitor(openshiftMonitoringNS, s), metav1.CreateOptions{}) + smc, err := mclient.ServiceMonitors(openshiftMonitoringNS).Create(ctx, GenerateServiceMonitor(openshiftMonitoringNS, s), + metav1.CreateOptions{}) missingNS, _ := resource.IsMissingNamespaceErr(err) if missingNS {