fix: [fs] an error upon rwPool.Write() just attempt rwPool.Create() (#10533)

On some NFS clients looks like errno is incorrectly set,
which leads to incorrect errors thrown upwards.
This commit is contained in:
Harshavardhana 2020-09-21 12:54:23 -07:00 committed by GitHub
parent aa12d75d75
commit a5da9120f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 13 deletions

View File

@ -157,6 +157,9 @@ func (fsi *fsIOPool) Write(path string) (wlk *lock.LockedFile, err error) {
case isSysErrIsDir(err):
return nil, errIsNotRegular
default:
if isSysErrPathNotFound(err) {
return nil, errFileNotFound
}
return nil, err
}
}

View File

@ -19,7 +19,6 @@ package cmd
import (
"bytes"
"context"
"errors"
"fmt"
"io"
"io/ioutil"
@ -623,10 +622,6 @@ func (fs *FSObjects) CopyObject(ctx context.Context, srcBucket, srcObject, dstBu
fsMetaPath := pathJoin(fs.fsPath, minioMetaBucket, bucketMetaPrefix, srcBucket, srcObject, fs.metaJSONFile)
wlk, err := fs.rwPool.Write(fsMetaPath)
if err != nil {
if !errors.Is(err, errFileNotFound) {
logger.LogIf(ctx, err)
return oi, toObjectErr(err, srcBucket, srcObject)
}
wlk, err = fs.rwPool.Create(fsMetaPath)
if err != nil {
logger.LogIf(ctx, err)
@ -1177,10 +1172,6 @@ func (fs *FSObjects) putObject(ctx context.Context, bucket string, object string
wlk, err = fs.rwPool.Write(fsMetaPath)
var freshFile bool
if err != nil {
if !errors.Is(err, errFileNotFound) {
logger.LogIf(ctx, err)
return ObjectInfo{}, toObjectErr(err, bucket, object)
}
wlk, err = fs.rwPool.Create(fsMetaPath)
if err != nil {
logger.LogIf(ctx, err)
@ -1511,10 +1502,6 @@ func (fs *FSObjects) PutObjectTags(ctx context.Context, bucket, object string, t
fsMeta := fsMetaV1{}
wlk, err := fs.rwPool.Write(fsMetaPath)
if err != nil {
if !errors.Is(err, errFileNotFound) {
logger.LogIf(ctx, err)
return toObjectErr(err, bucket, object)
}
wlk, err = fs.rwPool.Create(fsMetaPath)
if err != nil {
logger.LogIf(ctx, err)

View File

@ -94,6 +94,10 @@ func isSysErrNotEmpty(err error) bool {
// Check if the given error corresponds to the specific ERROR_PATH_NOT_FOUND for windows
func isSysErrPathNotFound(err error) bool {
if runtime.GOOS != globalWindowsOSName {
var pathErr *os.PathError
if errors.As(err, &pathErr) {
return pathErr.Err == syscall.ENOENT
}
return false
}
var pathErr *os.PathError