Log disk not found error just once (#6059)

Modified the LogIf function to log only if the error passed
is not on the ignored errors list.

Currently, only disk not found error is added to the list.
Added a new function in logger package called LogAlwaysIf, 
which will print on any error.

Fixes #5997
master
kannappanr 6 years ago committed by Harshavardhana
parent ff29aed05d
commit 0286e61aee
  1. 30
      cmd/logger/logger.go
  2. 4
      cmd/prepare-storage.go
  3. 2
      cmd/xl-v1-bucket.go
  4. 1
      cmd/xl-v1-healing.go
  5. 2
      cmd/xl-v1-metadata.go
  6. 2
      cmd/xl-v1-multipart.go
  7. 1
      cmd/xl-v1-object.go

@ -47,6 +47,11 @@ const (
const loggerTimeFormat string = "15:04:05 MST 01/02/2006"
// List of error strings to be ignored by LogIf
const (
diskNotFoundError = "disk not found"
)
var matchingFuncNames = [...]string{
"http.HandlerFunc.ServeHTTP",
"cmd.serverMain",
@ -267,17 +272,36 @@ func getTrace(traceLevel int) []string {
return trace
}
// LogIf prints a detailed error message during
// LogAlwaysIf prints a detailed error message during
// the execution of the server.
func LogIf(ctx context.Context, err error) {
if Disable {
func LogAlwaysIf(ctx context.Context, err error) {
if err == nil {
return
}
logIf(ctx, err)
}
// LogIf prints a detailed error message during
// the execution of the server, if it is not an
// ignored error.
func LogIf(ctx context.Context, err error) {
if err == nil {
return
}
if err.Error() != diskNotFoundError {
logIf(ctx, err)
}
}
// logIf prints a detailed error message during
// the execution of the server.
func logIf(ctx context.Context, err error) {
if Disable {
return
}
req := GetReqInfo(ctx)
if req == nil {

@ -36,14 +36,14 @@ var printEndpointError = func() func(Endpoint, error) {
m = make(map[string]bool)
m[err.Error()] = true
printOnce[endpoint] = m
logger.LogIf(ctx, err)
logger.LogAlwaysIf(ctx, err)
return
}
if m[err.Error()] {
return
}
m[err.Error()] = true
logger.LogIf(ctx, err)
logger.LogAlwaysIf(ctx, err)
}
}()

@ -50,7 +50,6 @@ func (xl xlObjects) MakeBucketWithLocation(ctx context.Context, bucket, location
// Make a volume entry on all underlying storage disks.
for index, disk := range xl.getDisks() {
if disk == nil {
logger.LogIf(ctx, errDiskNotFound)
dErrs[index] = errDiskNotFound
continue
}
@ -234,7 +233,6 @@ func (xl xlObjects) DeleteBucket(ctx context.Context, bucket string) error {
// Remove a volume entry on all underlying storage disks.
for index, disk := range xl.getDisks() {
if disk == nil {
logger.LogIf(ctx, errDiskNotFound)
dErrs[index] = errDiskNotFound
continue
}

@ -108,7 +108,6 @@ func healBucket(ctx context.Context, storageDisks []StorageAPI, bucket string, w
// Make a volume entry on all underlying storage disks.
for index, disk := range storageDisks {
if disk == nil {
logger.LogIf(ctx, errDiskNotFound)
dErrs[index] = errDiskNotFound
beforeState[index] = madmin.DriveStateOffline
afterState[index] = madmin.DriveStateOffline

@ -428,7 +428,6 @@ func writeUniqueXLMetadata(ctx context.Context, disks []StorageAPI, bucket, pref
// Start writing `xl.json` to all disks in parallel.
for index, disk := range disks {
if disk == nil {
logger.LogIf(ctx, errDiskNotFound)
mErrs[index] = errDiskNotFound
continue
}
@ -467,7 +466,6 @@ func writeSameXLMetadata(ctx context.Context, disks []StorageAPI, bucket, prefix
// Start writing `xl.json` to all disks in parallel.
for index, disk := range disks {
if disk == nil {
logger.LogIf(ctx, errDiskNotFound)
mErrs[index] = errDiskNotFound
continue
}

@ -103,7 +103,6 @@ func commitXLMetadata(ctx context.Context, disks []StorageAPI, srcBucket, srcPre
// Rename `xl.json` to all disks in parallel.
for index, disk := range disks {
if disk == nil {
logger.LogIf(ctx, errDiskNotFound)
mErrs[index] = errDiskNotFound
continue
}
@ -791,7 +790,6 @@ func (xl xlObjects) cleanupUploadedParts(ctx context.Context, uploadIDPath strin
// Cleanup uploadID for all disks.
for index, disk := range xl.getDisks() {
if disk == nil {
logger.LogIf(ctx, errDiskNotFound)
errs[index] = errDiskNotFound
continue
}

@ -807,7 +807,6 @@ func (xl xlObjects) deleteObject(ctx context.Context, bucket, object string) err
for index, disk := range xl.getDisks() {
if disk == nil {
logger.LogIf(ctx, errDiskNotFound)
dErrs[index] = errDiskNotFound
continue
}

Loading…
Cancel
Save