From b392b0a3f2aaf27692c7d33730468a719658a23b Mon Sep 17 00:00:00 2001 From: Martin Schuppert Date: Wed, 9 Oct 2024 13:37:59 +0200 Subject: [PATCH] Do not ignore err on GetSecret() In CI jobs it was seen that the controller menager restarted due to a nil ptr when set the transport url in the config. The issue iss that when the TransportURL secret gets fetched, no check is perforned if an error happened. This adds the err checks on the TransportURL and Password secret. Signed-off-by: Martin Schuppert --- controllers/ceilometer_controller.go | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/controllers/ceilometer_controller.go b/controllers/ceilometer_controller.go index ab3576f9..8f2758da 100644 --- a/controllers/ceilometer_controller.go +++ b/controllers/ceilometer_controller.go @@ -818,8 +818,15 @@ func (r *CeilometerReconciler) generateServiceConfig( return err } - transportURLSecret, _, _ := secret.GetSecret(ctx, h, instance.CeilometerStatus.TransportURLSecret, instance.Namespace) - ceilometerPasswordSecret, _, _ := secret.GetSecret(ctx, h, instance.Spec.Secret, instance.Namespace) + transportURLSecret, _, err := secret.GetSecret(ctx, h, instance.CeilometerStatus.TransportURLSecret, instance.Namespace) + if err != nil { + return err + } + + ceilometerPasswordSecret, _, err := secret.GetSecret(ctx, h, instance.Spec.Secret, instance.Namespace) + if err != nil { + return err + } templateParameters := map[string]interface{}{ "KeystoneInternalURL": keystoneInternalURL, @@ -891,8 +898,15 @@ func (r *CeilometerReconciler) generateComputeServiceConfig( return err } - transportURLSecret, _, _ := secret.GetSecret(ctx, h, instance.CeilometerStatus.TransportURLSecret, instance.Namespace) - ceilometerPasswordSecret, _, _ := secret.GetSecret(ctx, h, instance.Spec.Secret, instance.Namespace) + transportURLSecret, _, err := secret.GetSecret(ctx, h, instance.CeilometerStatus.TransportURLSecret, instance.Namespace) + if err != nil { + return err + } + + ceilometerPasswordSecret, _, err := secret.GetSecret(ctx, h, instance.Spec.Secret, instance.Namespace) + if err != nil { + return err + } templateParameters := map[string]interface{}{ "KeystoneInternalURL": keystoneInternalURL,