remove unnecessary logging and move to log once (#10798)

the current master logs way too much when a node
is down, instead log once and move on.
This commit is contained in:
Harshavardhana
2020-10-30 14:55:50 -07:00
committed by GitHub
parent 02cfa774be
commit 5e5cdc581d
5 changed files with 39 additions and 11 deletions

View File

@@ -23,6 +23,7 @@ import (
"fmt"
"go/build"
"hash"
"net/http"
"path/filepath"
"reflect"
"runtime"
@@ -299,9 +300,17 @@ func LogIf(ctx context.Context, err error, errKind ...interface{}) {
return
}
if !errors.Is(err, context.Canceled) {
logIf(ctx, err, errKind...)
if errors.Is(err, context.Canceled) || errors.Is(err, http.ErrServerClosed) {
return
}
if e := errors.Unwrap(err); e != nil {
if e.Error() == "disk not found" {
return
}
}
logIf(ctx, err, errKind...)
}
// logIf prints a detailed error message during

View File

@@ -18,6 +18,8 @@ package logger
import (
"context"
"errors"
"net/http"
"sync"
"time"
@@ -77,5 +79,19 @@ var logOnce = newLogOnceType()
// id is a unique identifier for related log messages, refer to cmd/notification.go
// on how it is used.
func LogOnceIf(ctx context.Context, err error, id interface{}, errKind ...interface{}) {
if err == nil {
return
}
if errors.Is(err, context.Canceled) || errors.Is(err, http.ErrServerClosed) {
return
}
if e := errors.Unwrap(err); e != nil {
if e.Error() == "disk not found" {
return
}
}
logOnce.logOnceIf(ctx, err, id, errKind...)
}