mirror of
https://github.com/minio/minio.git
synced 2024-12-24 22:25:54 -05:00
Fix unnecessary log messages to avoid flooding the logs (#5900)
This commit is contained in:
parent
9de8fefa90
commit
bb34bd91f1
@ -225,6 +225,15 @@ func fsStatDir(ctx context.Context, statDir string) (os.FileInfo, error) {
|
|||||||
return fi, nil
|
return fi, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns if the dirPath is a directory.
|
||||||
|
func fsIsDir(ctx context.Context, dirPath string) bool {
|
||||||
|
fi, err := fsStat(ctx, dirPath)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return fi.IsDir()
|
||||||
|
}
|
||||||
|
|
||||||
// Lookup if file exists, returns file attributes upon success.
|
// Lookup if file exists, returns file attributes upon success.
|
||||||
func fsStatFile(ctx context.Context, statFile string) (os.FileInfo, error) {
|
func fsStatFile(ctx context.Context, statFile string) (os.FileInfo, error) {
|
||||||
fi, err := fsStat(ctx, statFile)
|
fi, err := fsStat(ctx, statFile)
|
||||||
@ -242,6 +251,15 @@ func fsStatFile(ctx context.Context, statFile string) (os.FileInfo, error) {
|
|||||||
return fi, nil
|
return fi, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns if the filePath is a regular file.
|
||||||
|
func fsIsFile(ctx context.Context, filePath string) bool {
|
||||||
|
fi, err := fsStat(ctx, filePath)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return fi.Mode().IsRegular()
|
||||||
|
}
|
||||||
|
|
||||||
// Opens the file at given path, optionally from an offset. Upon success returns
|
// Opens the file at given path, optionally from an offset. Upon success returns
|
||||||
// a readable stream and the size of the readable stream.
|
// a readable stream and the size of the readable stream.
|
||||||
func fsOpenFile(ctx context.Context, readPath string, offset int64) (io.ReadCloser, int64, error) {
|
func fsOpenFile(ctx context.Context, readPath string, offset int64) (io.ReadCloser, int64, error) {
|
||||||
@ -402,7 +420,9 @@ func fsDeleteFile(ctx context.Context, basePath, deletePath string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := deleteFile(basePath, deletePath); err != nil {
|
if err := deleteFile(basePath, deletePath); err != nil {
|
||||||
logger.LogIf(ctx, err)
|
if err != errFileNotFound {
|
||||||
|
logger.LogIf(ctx, err)
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -547,3 +547,33 @@ func TestFSRemoveMeta(t *testing.T) {
|
|||||||
t.Fatalf("`%s` parent directory found though it should have been deleted.", filePath)
|
t.Fatalf("`%s` parent directory found though it should have been deleted.", filePath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestFSIsDir(t *testing.T) {
|
||||||
|
dirPath, err := ioutil.TempDir(globalTestTmpDir, "minio-")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Unable to create tmp directory %s", err)
|
||||||
|
}
|
||||||
|
defer os.RemoveAll(dirPath)
|
||||||
|
|
||||||
|
if !fsIsDir(context.Background(), dirPath) {
|
||||||
|
t.Fatalf("Expected %s to be a directory", dirPath)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFSIsFile(t *testing.T) {
|
||||||
|
dirPath, err := ioutil.TempDir(globalTestTmpDir, "minio-")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Unable to create tmp directory %s", err)
|
||||||
|
}
|
||||||
|
defer os.RemoveAll(dirPath)
|
||||||
|
|
||||||
|
filePath := pathJoin(dirPath, "tmpfile")
|
||||||
|
|
||||||
|
if err = ioutil.WriteFile(filePath, nil, 0777); err != nil {
|
||||||
|
t.Fatalf("Unable to create file %s", filePath)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !fsIsFile(context.Background(), filePath) {
|
||||||
|
t.Fatalf("Expected %s to be a file", filePath)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
23
cmd/fs-v1.go
23
cmd/fs-v1.go
@ -563,17 +563,16 @@ func (fs *FSObjects) defaultFsJSON(object string) fsMetaV1 {
|
|||||||
// getObjectInfo - wrapper for reading object metadata and constructs ObjectInfo.
|
// getObjectInfo - wrapper for reading object metadata and constructs ObjectInfo.
|
||||||
func (fs *FSObjects) getObjectInfo(ctx context.Context, bucket, object string) (oi ObjectInfo, e error) {
|
func (fs *FSObjects) getObjectInfo(ctx context.Context, bucket, object string) (oi ObjectInfo, e error) {
|
||||||
fsMeta := fsMetaV1{}
|
fsMeta := fsMetaV1{}
|
||||||
fi, err := fsStatDir(ctx, pathJoin(fs.fsPath, bucket, object))
|
if hasSuffix(object, slashSeparator) {
|
||||||
if err != nil && err != errFileAccessDenied {
|
// Since we support PUT of a "directory" object, we allow HEAD.
|
||||||
return oi, err
|
if !fsIsDir(ctx, pathJoin(fs.fsPath, bucket, object)) {
|
||||||
}
|
return oi, errFileNotFound
|
||||||
if fi != nil {
|
|
||||||
// If file found and request was with object ending with "/", consider it
|
|
||||||
// as directory and return object info
|
|
||||||
if hasSuffix(object, slashSeparator) {
|
|
||||||
return fsMeta.ToObjectInfo(bucket, object, fi), nil
|
|
||||||
}
|
}
|
||||||
return oi, errFileNotFound
|
fi, err := fsStatDir(ctx, pathJoin(fs.fsPath, bucket, object))
|
||||||
|
if err != nil {
|
||||||
|
return oi, err
|
||||||
|
}
|
||||||
|
return fsMeta.ToObjectInfo(bucket, object, fi), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
fsMetaPath := pathJoin(fs.fsPath, minioMetaBucket, bucketMetaPrefix, bucket, object, fs.metaJSONFile)
|
fsMetaPath := pathJoin(fs.fsPath, minioMetaBucket, bucketMetaPrefix, bucket, object, fs.metaJSONFile)
|
||||||
@ -602,7 +601,7 @@ func (fs *FSObjects) getObjectInfo(ctx context.Context, bucket, object string) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Stat the file to get file size.
|
// Stat the file to get file size.
|
||||||
fi, err = fsStatFile(ctx, pathJoin(fs.fsPath, bucket, object))
|
fi, err := fsStatFile(ctx, pathJoin(fs.fsPath, bucket, object))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return oi, err
|
return oi, err
|
||||||
}
|
}
|
||||||
@ -664,7 +663,7 @@ func (fs *FSObjects) parentDirIsObject(ctx context.Context, bucket, parent strin
|
|||||||
if p == "." || p == "/" {
|
if p == "." || p == "/" {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if _, err := fsStatFile(ctx, pathJoin(fs.fsPath, bucket, p)); err == nil {
|
if fsIsFile(ctx, pathJoin(fs.fsPath, bucket, p)) {
|
||||||
// If there is already a file at prefix "p", return true.
|
// If there is already a file at prefix "p", return true.
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,6 @@ func (xl xlObjects) getBucketInfo(ctx context.Context, bucketName string) (bucke
|
|||||||
}
|
}
|
||||||
return bucketInfo, nil
|
return bucketInfo, nil
|
||||||
}
|
}
|
||||||
logger.LogIf(ctx, serr)
|
|
||||||
err = serr
|
err = serr
|
||||||
// For any reason disk went offline continue and pick the next one.
|
// For any reason disk went offline continue and pick the next one.
|
||||||
if IsErrIgnored(err, bucketMetadataOpIgnoredErrs...) {
|
if IsErrIgnored(err, bucketMetadataOpIgnoredErrs...) {
|
||||||
|
@ -832,7 +832,6 @@ func (xl xlObjects) DeleteObject(ctx context.Context, bucket, object string) (er
|
|||||||
|
|
||||||
// Validate object exists.
|
// Validate object exists.
|
||||||
if !xl.isObject(bucket, object) {
|
if !xl.isObject(bucket, object) {
|
||||||
logger.LogIf(ctx, ObjectNotFound{bucket, object})
|
|
||||||
return ObjectNotFound{bucket, object}
|
return ObjectNotFound{bucket, object}
|
||||||
} // else proceed to delete the object.
|
} // else proceed to delete the object.
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ func reduceErrs(errs []error, ignoredErrs []error) (maxCount int, maxErr error)
|
|||||||
func reduceQuorumErrs(ctx context.Context, errs []error, ignoredErrs []error, quorum int, quorumErr error) error {
|
func reduceQuorumErrs(ctx context.Context, errs []error, ignoredErrs []error, quorum int, quorumErr error) error {
|
||||||
maxCount, maxErr := reduceErrs(errs, ignoredErrs)
|
maxCount, maxErr := reduceErrs(errs, ignoredErrs)
|
||||||
if maxCount >= quorum {
|
if maxCount >= quorum {
|
||||||
if maxErr != errFileNotFound {
|
if maxErr != errFileNotFound && maxErr != errVolumeNotFound {
|
||||||
logger.LogIf(ctx, maxErr)
|
logger.LogIf(ctx, maxErr)
|
||||||
}
|
}
|
||||||
return maxErr
|
return maxErr
|
||||||
|
Loading…
Reference in New Issue
Block a user