Skip to content

Commit

Permalink
Use correct request namespace when creating ServiceMonitors
Browse files Browse the repository at this point in the history
Use "openshiftMonitoringNS" instead of "ns" when first attempting to
create in the former namespace.

Signed-off-by: Tom Pantelis <[email protected]>
  • Loading branch information
tpantelis authored and dfarrell07 committed May 7, 2024
1 parent 626f4e8 commit d191623
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/metrics/service-monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit d191623

Please sign in to comment.