From 8c376fe86f4e0182e875e0970341cd56a46cea87 Mon Sep 17 00:00:00 2001 From: Jaromir Wysoglad Date: Fri, 15 Mar 2024 10:12:29 -0400 Subject: [PATCH] Get telemetry CR before trying to read from it --- pkg/openstack/telemetry.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/openstack/telemetry.go b/pkg/openstack/telemetry.go index ab1aba1d8..3262e80e5 100644 --- a/pkg/openstack/telemetry.go +++ b/pkg/openstack/telemetry.go @@ -11,7 +11,9 @@ import ( corev1beta1 "github.com/openstack-k8s-operators/openstack-operator/apis/core/v1beta1" telemetryv1 "github.com/openstack-k8s-operators/telemetry-operator/api/v1beta1" + k8s_errors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" ) @@ -39,6 +41,12 @@ func ReconcileTelemetry(ctx context.Context, instance *corev1beta1.OpenStackCont return ctrl.Result{}, nil } + if err := helper.GetClient().Get(ctx, types.NamespacedName{Name: "telemetry", Namespace: instance.Namespace}, telemetry); err != nil { + if !k8s_errors.IsNotFound(err) { + return ctrl.Result{}, err + } + } + // add selector to service overrides for _, endpointType := range []service.Endpoint{service.EndpointPublic, service.EndpointInternal} { if instance.Spec.Telemetry.Template.Autoscaling.Aodh.Override.Service == nil {