From 4cbaacf95aefcf324a249a8f2e22c26e28488771 Mon Sep 17 00:00:00 2001 From: Thibault Mange <22740367+thibaultmg@users.noreply.github.com> Date: Wed, 17 Jul 2024 09:36:40 +0200 Subject: [PATCH] fix clusterVersion check Signed-off-by: Thibault Mange <22740367+thibaultmg@users.noreply.github.com> --- .../observabilityaddon_controller.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/operators/endpointmetrics/controllers/observabilityendpoint/observabilityaddon_controller.go b/operators/endpointmetrics/controllers/observabilityendpoint/observabilityaddon_controller.go index 60e6141bcb..6d79942985 100644 --- a/operators/endpointmetrics/controllers/observabilityendpoint/observabilityaddon_controller.go +++ b/operators/endpointmetrics/controllers/observabilityendpoint/observabilityaddon_controller.go @@ -213,10 +213,15 @@ func (r *ObservabilityAddonReconciler) Reconcile(ctx context.Context, req ctrl.R clusterID, err = openshift.GetClusterID(ctx, r.Client) if err != nil { - if !errors.IsNotFound(err) { + if errors.IsInvalid(err) { + // ClusterVersion kind does not exist in OCP 3.x + log.Info("ClusterVersion kind does not exist in OCP 3.x") + } else if errors.IsNotFound(err) { return ctrl.Result{}, fmt.Errorf("failed to get cluster id: %w", err) + } else { + // TODO: once the IsInvalid check is validated on OCP 3.x, return error instead of logging (merge with the previous if block) + log.Error(err, "Failed to get cluster id") } - log.Error(err, "Failed to get cluster id") // OCP 3.11 has no cluster id, set it as empty string clusterID = ""