Skip to content

Commit

Permalink
Convert some remaining error logs into errors with stack traces to im…
Browse files Browse the repository at this point in the history
…prove error reporting (#348)
  • Loading branch information
orishoshan committed Jan 28, 2024
1 parent 3e4f724 commit dfb2de8
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/operator/controllers/intents_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
Expand Down
1 change: 1 addition & 0 deletions src/operator/controllers/kafkaserverconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
Expand Down
3 changes: 1 addition & 2 deletions src/operator/controllers/pod_reconcilers/pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 5 additions & 6 deletions src/shared/otterizecloud/otterizecloudclient/cloud_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
Expand All @@ -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)
}
}

Expand Down
6 changes: 5 additions & 1 deletion src/shared/telemetries/basicbatch/batcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 1 addition & 2 deletions src/shared/telemetries/telemetrysender/sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
}
Expand Down

0 comments on commit dfb2de8

Please sign in to comment.