diff --git a/src/operator/controllers/intents_controller.go b/src/operator/controllers/intents_controller.go index 404907263..da4d019aa 100644 --- a/src/operator/controllers/intents_controller.go +++ b/src/operator/controllers/intents_controller.go @@ -262,6 +262,7 @@ func (r *IntentsReconciler) getIntentsToProtectedService(protectedService *otter ) if err != nil { logrus.Errorf("Failed to list client intents for client %s: %v", fullServerName, err) + // Intentionally no return - we are not able to return errors in this flow currently } intentsToReconcile = append(intentsToReconcile, intentsToServer.Items...) diff --git a/src/operator/controllers/kafkaserverconfig_controller.go b/src/operator/controllers/kafkaserverconfig_controller.go index e88492ea5..46c113ff8 100644 --- a/src/operator/controllers/kafkaserverconfig_controller.go +++ b/src/operator/controllers/kafkaserverconfig_controller.go @@ -147,6 +147,7 @@ func (r *KafkaServerConfigReconciler) getKSCsForProtectedService(ctx context.Con ) if err != nil { logrus.Errorf("Failed to list KSCs for server %s: %v", protectedService.Spec.Name, err) + // Intentionally no return - we are not able to return errors in this flow currently } kscsToReconcile = append(kscsToReconcile, kafkaServerConfigs.Items...) diff --git a/src/operator/controllers/pod_reconcilers/pods.go b/src/operator/controllers/pod_reconcilers/pods.go index f4c240b51..a52525524 100644 --- a/src/operator/controllers/pod_reconcilers/pods.go +++ b/src/operator/controllers/pod_reconcilers/pods.go @@ -223,8 +223,7 @@ func (p *PodWatcher) addOtterizePodLabels(ctx context.Context, req ctrl.Request, if hasUpdates { err = p.Patch(ctx, updatedPod, client.MergeFrom(&pod)) if err != nil { - logrus.Errorf("Failed updating Otterize labels for pod %s in namespace %s", pod.Name, pod.Namespace) - return errors.Wrap(err) + return errors.Errorf("failed updating Otterize labels for pod %s in namespace %s: %w", pod.Name, pod.Namespace, err) } } return nil diff --git a/src/shared/otterizecloud/otterizecloudclient/cloud_client.go b/src/shared/otterizecloud/otterizecloudclient/cloud_client.go index db48469e7..455d9b4f6 100644 --- a/src/shared/otterizecloud/otterizecloudclient/cloud_client.go +++ b/src/shared/otterizecloud/otterizecloudclient/cloud_client.go @@ -4,9 +4,9 @@ import ( "context" "crypto/tls" "crypto/x509" - "errors" "fmt" "github.com/Khan/genqlient/graphql" + "github.com/otterize/intents-operator/src/shared/errors" "github.com/otterize/intents-operator/src/shared/telemetries/componentinfo" "github.com/sirupsen/logrus" "github.com/spf13/viper" @@ -26,10 +26,10 @@ func NewClient(ctx context.Context) (graphql.Client, bool, error) { return nil, false, nil } if clientID == "" { - return nil, true, errors.New("missing cloud integration client ID") + return nil, false, errors.New("missing cloud integration client ID") } if secret == "" { - return nil, true, errors.New("missing cloud integration secret") + return nil, false, errors.New("missing cloud integration secret") } componentinfo.SetGlobalCloudClientId(clientID) @@ -49,12 +49,11 @@ func NewClient(ctx context.Context) (graphql.Client, bool, error) { logrus.Infof("Loading root CA from cert PEM file at '%s'", path) cert, err := os.ReadFile(path) if err != nil { - logrus.Errorf("Error loading cert PEM file at '%s', trying to continue without it: %s", path, err) - continue + return nil, false, errors.Errorf("error loading cert PEM file at '%s', trying to continue without it: %w", path, err) } if ok := rootCAs.AppendCertsFromPEM(cert); !ok { - logrus.Warnf("Failed appending cert PEM file at '%s', trying to continue without it", path) + return nil, false, errors.Errorf("Failed appending cert PEM file at '%s', trying to continue without it", path) } } diff --git a/src/shared/telemetries/basicbatch/batcher.go b/src/shared/telemetries/basicbatch/batcher.go index df2ac2120..40953573c 100644 --- a/src/shared/telemetries/basicbatch/batcher.go +++ b/src/shared/telemetries/basicbatch/batcher.go @@ -51,7 +51,11 @@ func (b *Batcher[T]) runForever() { defer func() { r := recover() if r != nil { - logrus.Error("recovered from panic in batcher") + logger := logrus.WithField("panic", r) + if rErr, ok := r.(error); ok { + logger = logger.WithError(rErr) + } + logger.Error("recovered from panic in batcher: %r") } }() defer errorreporter.AutoNotify() diff --git a/src/shared/telemetries/telemetrysender/sender.go b/src/shared/telemetries/telemetrysender/sender.go index 781217e3f..5c3473376 100644 --- a/src/shared/telemetries/telemetrysender/sender.go +++ b/src/shared/telemetries/telemetrysender/sender.go @@ -7,7 +7,6 @@ import ( "github.com/otterize/intents-operator/src/shared/telemetries/basicbatch" "github.com/otterize/intents-operator/src/shared/telemetries/telemetriesconfig" "github.com/otterize/intents-operator/src/shared/telemetries/telemetriesgql" - "github.com/sirupsen/logrus" "github.com/spf13/viper" "net/http" "time" @@ -34,7 +33,7 @@ func newGqlClient() graphql.Client { func batchSendTelemetries(ctx context.Context, telemetriesClient graphql.Client, telemetries []telemetriesgql.TelemetryInput) error { _, err := telemetriesgql.SendTelemetries(ctx, telemetriesClient, telemetries) if err != nil { - logrus.Errorf("failed batch sending telemetries: %s", err) + return errors.Errorf("failed batch sending telemetries: %w", err) } return nil }