mirror of
https://github.com/minio/minio.git
synced 2024-12-26 15:15:55 -05:00
remove all unnecessary logging, logOnce when absolutely needed (#17965)
This commit is contained in:
parent
d665e855de
commit
8208bcb896
@ -19,7 +19,6 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"errors"
|
"errors"
|
||||||
@ -1422,7 +1421,6 @@ func (x *xlMetaV2) DeleteVersion(fi FileInfo) (string, error) {
|
|||||||
err = x.addVersion(freeVersion)
|
err = x.addVersion(freeVersion)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logger.LogIf(context.Background(), err)
|
|
||||||
|
|
||||||
if fi.Deleted {
|
if fi.Deleted {
|
||||||
err = x.addVersion(ventry)
|
err = x.addVersion(ventry)
|
||||||
|
@ -193,9 +193,6 @@ func getValidPath(path string) (string, error) {
|
|||||||
func isDirEmpty(dirname string) bool {
|
func isDirEmpty(dirname string) bool {
|
||||||
entries, err := readDirN(dirname, 1)
|
entries, err := readDirN(dirname, 1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err != errFileNotFound {
|
|
||||||
logger.LogIf(GlobalContext, err)
|
|
||||||
}
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return len(entries) == 0
|
return len(entries) == 0
|
||||||
@ -707,12 +704,12 @@ func (s *xlStorage) checkFormatJSON() (os.FileInfo, error) {
|
|||||||
} else if osIsPermission(err) {
|
} else if osIsPermission(err) {
|
||||||
return nil, errDiskAccessDenied
|
return nil, errDiskAccessDenied
|
||||||
}
|
}
|
||||||
logger.LogOnceIf(GlobalContext, err, err.Error()) // log unexpected errors
|
logger.LogOnceIf(GlobalContext, err, "check-format-json") // log unexpected errors
|
||||||
return nil, errCorruptedFormat
|
return nil, errCorruptedFormat
|
||||||
} else if osIsPermission(err) {
|
} else if osIsPermission(err) {
|
||||||
return nil, errDiskAccessDenied
|
return nil, errDiskAccessDenied
|
||||||
}
|
}
|
||||||
logger.LogOnceIf(GlobalContext, err, err.Error()) // log unexpected errors
|
logger.LogOnceIf(GlobalContext, err, "check-format-json") // log unexpected errors
|
||||||
return nil, errCorruptedFormat
|
return nil, errCorruptedFormat
|
||||||
}
|
}
|
||||||
return fi, nil
|
return fi, nil
|
||||||
@ -759,19 +756,19 @@ func (s *xlStorage) GetDiskID() (string, error) {
|
|||||||
} else if osIsPermission(err) {
|
} else if osIsPermission(err) {
|
||||||
return "", errDiskAccessDenied
|
return "", errDiskAccessDenied
|
||||||
}
|
}
|
||||||
logger.LogIf(GlobalContext, err) // log unexpected errors
|
logger.LogOnceIf(GlobalContext, err, "check-format-json") // log unexpected errors
|
||||||
return "", errCorruptedFormat
|
return "", errCorruptedFormat
|
||||||
} else if osIsPermission(err) {
|
} else if osIsPermission(err) {
|
||||||
return "", errDiskAccessDenied
|
return "", errDiskAccessDenied
|
||||||
}
|
}
|
||||||
logger.LogIf(GlobalContext, err) // log unexpected errors
|
logger.LogOnceIf(GlobalContext, err, "check-format-json") // log unexpected errors
|
||||||
return "", errCorruptedFormat
|
return "", errCorruptedFormat
|
||||||
}
|
}
|
||||||
|
|
||||||
format := &formatErasureV3{}
|
format := &formatErasureV3{}
|
||||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||||
if err = json.Unmarshal(b, &format); err != nil {
|
if err = json.Unmarshal(b, &format); err != nil {
|
||||||
logger.LogIf(GlobalContext, err) // log unexpected errors
|
logger.LogOnceIf(GlobalContext, err, "check-format-json") // log unexpected errors
|
||||||
return "", errCorruptedFormat
|
return "", errCorruptedFormat
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -843,7 +840,6 @@ func listVols(ctx context.Context, dirPath string) ([]VolInfo, error) {
|
|||||||
}
|
}
|
||||||
entries, err := readDir(dirPath)
|
entries, err := readDir(dirPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.LogIf(ctx, err)
|
|
||||||
if errors.Is(err, errFileAccessDenied) {
|
if errors.Is(err, errFileAccessDenied) {
|
||||||
return nil, errDiskAccessDenied
|
return nil, errDiskAccessDenied
|
||||||
} else if errors.Is(err, errFileNotFound) {
|
} else if errors.Is(err, errFileNotFound) {
|
||||||
@ -1240,7 +1236,6 @@ func (s *xlStorage) UpdateMetadata(ctx context.Context, volume, path string, fi
|
|||||||
|
|
||||||
var xlMeta xlMetaV2
|
var xlMeta xlMetaV2
|
||||||
if err = xlMeta.Load(buf); err != nil {
|
if err = xlMeta.Load(buf); err != nil {
|
||||||
logger.LogIf(ctx, err)
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1262,13 +1257,11 @@ func (s *xlStorage) WriteMetadata(ctx context.Context, volume, path string, fi F
|
|||||||
if fi.Fresh {
|
if fi.Fresh {
|
||||||
var xlMeta xlMetaV2
|
var xlMeta xlMetaV2
|
||||||
if err := xlMeta.AddVersion(fi); err != nil {
|
if err := xlMeta.AddVersion(fi); err != nil {
|
||||||
logger.LogIf(ctx, err)
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
buf, err := xlMeta.AppendTo(metaDataPoolGet())
|
buf, err := xlMeta.AppendTo(metaDataPoolGet())
|
||||||
defer metaDataPoolPut(buf)
|
defer metaDataPoolPut(buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.LogIf(ctx, err)
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// First writes for special situations do not write to stable storage.
|
// First writes for special situations do not write to stable storage.
|
||||||
@ -1287,34 +1280,28 @@ func (s *xlStorage) WriteMetadata(ctx context.Context, volume, path string, fi F
|
|||||||
var xlMeta xlMetaV2
|
var xlMeta xlMetaV2
|
||||||
if !isXL2V1Format(buf) {
|
if !isXL2V1Format(buf) {
|
||||||
// This is both legacy and without proper version.
|
// This is both legacy and without proper version.
|
||||||
err = xlMeta.AddVersion(fi)
|
if err = xlMeta.AddVersion(fi); err != nil {
|
||||||
if err != nil {
|
|
||||||
logger.LogIf(ctx, err)
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
buf, err = xlMeta.AppendTo(metaDataPoolGet())
|
buf, err = xlMeta.AppendTo(metaDataPoolGet())
|
||||||
defer metaDataPoolPut(buf)
|
defer metaDataPoolPut(buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.LogIf(ctx, err)
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if err = xlMeta.Load(buf); err != nil {
|
if err = xlMeta.Load(buf); err != nil {
|
||||||
logger.LogIf(ctx, err)
|
|
||||||
// Corrupted data, reset and write.
|
// Corrupted data, reset and write.
|
||||||
xlMeta = xlMetaV2{}
|
xlMeta = xlMetaV2{}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = xlMeta.AddVersion(fi); err != nil {
|
if err = xlMeta.AddVersion(fi); err != nil {
|
||||||
logger.LogIf(ctx, err)
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
buf, err = xlMeta.AppendTo(metaDataPoolGet())
|
buf, err = xlMeta.AppendTo(metaDataPoolGet())
|
||||||
defer metaDataPoolPut(buf)
|
defer metaDataPoolPut(buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.LogIf(ctx, err)
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2336,7 +2323,6 @@ func (s *xlStorage) RenameData(ctx context.Context, srcVolume, srcPath string, f
|
|||||||
if len(dstBuf) > 0 {
|
if len(dstBuf) > 0 {
|
||||||
if isXL2V1Format(dstBuf) {
|
if isXL2V1Format(dstBuf) {
|
||||||
if err = xlMeta.Load(dstBuf); err != nil {
|
if err = xlMeta.Load(dstBuf); err != nil {
|
||||||
logger.LogIf(ctx, err)
|
|
||||||
// Data appears corrupt. Drop data.
|
// Data appears corrupt. Drop data.
|
||||||
xlMeta = xlMetaV2{}
|
xlMeta = xlMetaV2{}
|
||||||
}
|
}
|
||||||
@ -2478,7 +2464,6 @@ func (s *xlStorage) RenameData(ctx context.Context, srcVolume, srcPath string, f
|
|||||||
dstBuf, err = xlMeta.AppendTo(metaDataPoolGet())
|
dstBuf, err = xlMeta.AppendTo(metaDataPoolGet())
|
||||||
defer metaDataPoolPut(dstBuf)
|
defer metaDataPoolPut(dstBuf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.LogIf(ctx, err)
|
|
||||||
if legacyPreserved {
|
if legacyPreserved {
|
||||||
// Any failed rename calls un-roll previous transaction.
|
// Any failed rename calls un-roll previous transaction.
|
||||||
s.deleteFile(dstVolumeDir, legacyDataPath, true, false)
|
s.deleteFile(dstVolumeDir, legacyDataPath, true, false)
|
||||||
@ -2690,9 +2675,11 @@ func (s *xlStorage) VerifyFile(ctx context.Context, volume, path string, fi File
|
|||||||
errFileNotFound,
|
errFileNotFound,
|
||||||
errVolumeNotFound,
|
errVolumeNotFound,
|
||||||
errFileCorrupt,
|
errFileCorrupt,
|
||||||
|
errFileAccessDenied,
|
||||||
|
errFileVersionNotFound,
|
||||||
}...) {
|
}...) {
|
||||||
logger.GetReqInfo(ctx).AppendTags("disk", s.String())
|
logger.GetReqInfo(ctx).AppendTags("disk", s.String())
|
||||||
logger.LogIf(ctx, err)
|
logger.LogOnceIf(ctx, err, partPath)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user