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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 39 additions and 11 deletions

View File

@ -1191,7 +1191,7 @@ func (z *erasureServerSets) DeleteBucket(ctx context.Context, bucket string, for
// Note that set distribution is ignored so it should only be used in cases where // Note that set distribution is ignored so it should only be used in cases where
// data is not distributed across sets. // data is not distributed across sets.
// Errors are logged but individual disk failures are not returned. // Errors are logged but individual disk failures are not returned.
func (z *erasureServerSets) deleteAll(ctx context.Context, bucket, prefix string) error { func (z *erasureServerSets) deleteAll(ctx context.Context, bucket, prefix string) {
var wg sync.WaitGroup var wg sync.WaitGroup
for _, servers := range z.serverSets { for _, servers := range z.serverSets {
for _, set := range servers.sets { for _, set := range servers.sets {
@ -1202,13 +1202,20 @@ func (z *erasureServerSets) deleteAll(ctx context.Context, bucket, prefix string
wg.Add(1) wg.Add(1)
go func(disk StorageAPI) { go func(disk StorageAPI) {
defer wg.Done() defer wg.Done()
logger.LogIf(ctx, disk.Delete(ctx, bucket, prefix, true)) if err := disk.Delete(ctx, bucket, prefix, true); err != nil {
if !IsErrIgnored(err, []error{
errDiskNotFound,
errVolumeNotFound,
errFileNotFound,
}...) {
logger.LogOnceIf(ctx, err, disk.String())
}
}
}(disk) }(disk)
} }
} }
} }
wg.Wait() wg.Wait()
return nil
} }
// This function is used to undo a successful DeleteBucket operation. // This function is used to undo a successful DeleteBucket operation.

View File

@ -23,6 +23,7 @@ import (
"fmt" "fmt"
"go/build" "go/build"
"hash" "hash"
"net/http"
"path/filepath" "path/filepath"
"reflect" "reflect"
"runtime" "runtime"
@ -299,9 +300,17 @@ func LogIf(ctx context.Context, err error, errKind ...interface{}) {
return return
} }
if !errors.Is(err, context.Canceled) { if errors.Is(err, context.Canceled) || errors.Is(err, http.ErrServerClosed) {
logIf(ctx, err, errKind...) 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 // logIf prints a detailed error message during

View File

@ -18,6 +18,8 @@ package logger
import ( import (
"context" "context"
"errors"
"net/http"
"sync" "sync"
"time" "time"
@ -77,5 +79,19 @@ var logOnce = newLogOnceType()
// id is a unique identifier for related log messages, refer to cmd/notification.go // id is a unique identifier for related log messages, refer to cmd/notification.go
// on how it is used. // on how it is used.
func LogOnceIf(ctx context.Context, err error, id interface{}, errKind ...interface{}) { 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...) logOnce.logOnceIf(ctx, err, id, errKind...)
} }

View File

@ -398,7 +398,7 @@ func (b *bucketMetacache) deleteAll() {
wg.Add(1) wg.Add(1)
go func(cache metacache) { go func(cache metacache) {
defer wg.Done() defer wg.Done()
logger.LogIf(ctx, ez.deleteAll(ctx, minioMetaBucket, metacachePrefixForID(cache.bucket, cache.id))) ez.deleteAll(ctx, minioMetaBucket, metacachePrefixForID(cache.bucket, cache.id))
}(b.caches[id]) }(b.caches[id])
delete(b.caches, id) delete(b.caches, id)
} }
@ -426,6 +426,6 @@ func (b *bucketMetacache) deleteCache(id string) {
logger.LogIf(ctx, errors.New("bucketMetacache: expected objAPI to be *erasureServerSets")) logger.LogIf(ctx, errors.New("bucketMetacache: expected objAPI to be *erasureServerSets"))
return return
} }
logger.LogIf(ctx, ez.deleteAll(ctx, minioMetaBucket, metacachePrefixForID(c.bucket, c.id))) ez.deleteAll(ctx, minioMetaBucket, metacachePrefixForID(c.bucket, c.id))
} }
} }

View File

@ -27,8 +27,6 @@ import (
"sync/atomic" "sync/atomic"
"time" "time"
"github.com/minio/minio/cmd/logger"
xhttp "github.com/minio/minio/cmd/http" xhttp "github.com/minio/minio/cmd/http"
xnet "github.com/minio/minio/pkg/net" xnet "github.com/minio/minio/pkg/net"
) )
@ -119,7 +117,6 @@ func (c *Client) Call(ctx context.Context, method string, values url.Values, bod
resp, err := c.httpClient.Do(req) resp, err := c.httpClient.Do(req)
if err != nil { if err != nil {
if xnet.IsNetworkOrHostDown(err, c.ExpectTimeouts) { if xnet.IsNetworkOrHostDown(err, c.ExpectTimeouts) {
logger.LogIf(ctx, err, "marking disk offline")
c.MarkOffline() c.MarkOffline()
} }
return nil, &NetworkError{err} return nil, &NetworkError{err}
@ -149,7 +146,6 @@ func (c *Client) Call(ctx context.Context, method string, values url.Values, bod
b, err := ioutil.ReadAll(io.LimitReader(resp.Body, c.MaxErrResponseSize)) b, err := ioutil.ReadAll(io.LimitReader(resp.Body, c.MaxErrResponseSize))
if err != nil { if err != nil {
if xnet.IsNetworkOrHostDown(err, c.ExpectTimeouts) { if xnet.IsNetworkOrHostDown(err, c.ExpectTimeouts) {
logger.LogIf(ctx, err, "marking disk offline")
c.MarkOffline() c.MarkOffline()
} }
return nil, err return nil, err