mirror of
https://github.com/minio/minio.git
synced 2025-01-11 15:03:22 -05:00
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
This commit is contained in:
parent
ff29aed05d
commit
0286e61aee
@ -47,6 +47,11 @@ const (
|
|||||||
|
|
||||||
const loggerTimeFormat string = "15:04:05 MST 01/02/2006"
|
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{
|
var matchingFuncNames = [...]string{
|
||||||
"http.HandlerFunc.ServeHTTP",
|
"http.HandlerFunc.ServeHTTP",
|
||||||
"cmd.serverMain",
|
"cmd.serverMain",
|
||||||
@ -267,17 +272,36 @@ func getTrace(traceLevel int) []string {
|
|||||||
return trace
|
return trace
|
||||||
}
|
}
|
||||||
|
|
||||||
// LogIf prints a detailed error message during
|
// LogAlwaysIf prints a detailed error message during
|
||||||
// the execution of the server.
|
// the execution of the server.
|
||||||
func LogIf(ctx context.Context, err error) {
|
func LogAlwaysIf(ctx context.Context, err error) {
|
||||||
if Disable {
|
if err == nil {
|
||||||
return
|
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 {
|
if err == nil {
|
||||||
return
|
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)
|
req := GetReqInfo(ctx)
|
||||||
|
|
||||||
if req == nil {
|
if req == nil {
|
||||||
|
@ -36,14 +36,14 @@ var printEndpointError = func() func(Endpoint, error) {
|
|||||||
m = make(map[string]bool)
|
m = make(map[string]bool)
|
||||||
m[err.Error()] = true
|
m[err.Error()] = true
|
||||||
printOnce[endpoint] = m
|
printOnce[endpoint] = m
|
||||||
logger.LogIf(ctx, err)
|
logger.LogAlwaysIf(ctx, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if m[err.Error()] {
|
if m[err.Error()] {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
m[err.Error()] = true
|
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.
|
// Make a volume entry on all underlying storage disks.
|
||||||
for index, disk := range xl.getDisks() {
|
for index, disk := range xl.getDisks() {
|
||||||
if disk == nil {
|
if disk == nil {
|
||||||
logger.LogIf(ctx, errDiskNotFound)
|
|
||||||
dErrs[index] = errDiskNotFound
|
dErrs[index] = errDiskNotFound
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -234,7 +233,6 @@ func (xl xlObjects) DeleteBucket(ctx context.Context, bucket string) error {
|
|||||||
// Remove a volume entry on all underlying storage disks.
|
// Remove a volume entry on all underlying storage disks.
|
||||||
for index, disk := range xl.getDisks() {
|
for index, disk := range xl.getDisks() {
|
||||||
if disk == nil {
|
if disk == nil {
|
||||||
logger.LogIf(ctx, errDiskNotFound)
|
|
||||||
dErrs[index] = errDiskNotFound
|
dErrs[index] = errDiskNotFound
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,6 @@ func healBucket(ctx context.Context, storageDisks []StorageAPI, bucket string, w
|
|||||||
// Make a volume entry on all underlying storage disks.
|
// Make a volume entry on all underlying storage disks.
|
||||||
for index, disk := range storageDisks {
|
for index, disk := range storageDisks {
|
||||||
if disk == nil {
|
if disk == nil {
|
||||||
logger.LogIf(ctx, errDiskNotFound)
|
|
||||||
dErrs[index] = errDiskNotFound
|
dErrs[index] = errDiskNotFound
|
||||||
beforeState[index] = madmin.DriveStateOffline
|
beforeState[index] = madmin.DriveStateOffline
|
||||||
afterState[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.
|
// Start writing `xl.json` to all disks in parallel.
|
||||||
for index, disk := range disks {
|
for index, disk := range disks {
|
||||||
if disk == nil {
|
if disk == nil {
|
||||||
logger.LogIf(ctx, errDiskNotFound)
|
|
||||||
mErrs[index] = errDiskNotFound
|
mErrs[index] = errDiskNotFound
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -467,7 +466,6 @@ func writeSameXLMetadata(ctx context.Context, disks []StorageAPI, bucket, prefix
|
|||||||
// Start writing `xl.json` to all disks in parallel.
|
// Start writing `xl.json` to all disks in parallel.
|
||||||
for index, disk := range disks {
|
for index, disk := range disks {
|
||||||
if disk == nil {
|
if disk == nil {
|
||||||
logger.LogIf(ctx, errDiskNotFound)
|
|
||||||
mErrs[index] = errDiskNotFound
|
mErrs[index] = errDiskNotFound
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,6 @@ func commitXLMetadata(ctx context.Context, disks []StorageAPI, srcBucket, srcPre
|
|||||||
// Rename `xl.json` to all disks in parallel.
|
// Rename `xl.json` to all disks in parallel.
|
||||||
for index, disk := range disks {
|
for index, disk := range disks {
|
||||||
if disk == nil {
|
if disk == nil {
|
||||||
logger.LogIf(ctx, errDiskNotFound)
|
|
||||||
mErrs[index] = errDiskNotFound
|
mErrs[index] = errDiskNotFound
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -791,7 +790,6 @@ func (xl xlObjects) cleanupUploadedParts(ctx context.Context, uploadIDPath strin
|
|||||||
// Cleanup uploadID for all disks.
|
// Cleanup uploadID for all disks.
|
||||||
for index, disk := range xl.getDisks() {
|
for index, disk := range xl.getDisks() {
|
||||||
if disk == nil {
|
if disk == nil {
|
||||||
logger.LogIf(ctx, errDiskNotFound)
|
|
||||||
errs[index] = errDiskNotFound
|
errs[index] = errDiskNotFound
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -807,7 +807,6 @@ func (xl xlObjects) deleteObject(ctx context.Context, bucket, object string) err
|
|||||||
|
|
||||||
for index, disk := range xl.getDisks() {
|
for index, disk := range xl.getDisks() {
|
||||||
if disk == nil {
|
if disk == nil {
|
||||||
logger.LogIf(ctx, errDiskNotFound)
|
|
||||||
dErrs[index] = errDiskNotFound
|
dErrs[index] = errDiskNotFound
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user