mirror of
https://github.com/minio/minio.git
synced 2025-04-11 15:07:48 -04:00
Use isErrIgnored() function wherever applicable. (#3343)
This commit is contained in:
parent
4ef2d8940c
commit
0f2e493c9a
@ -85,11 +85,9 @@ func loadAllBucketPolicies(objAPI ObjectLayer) (policies map[string]*bucketPolic
|
|||||||
for _, bucket := range buckets {
|
for _, bucket := range buckets {
|
||||||
policy, pErr := readBucketPolicy(bucket.Name, objAPI)
|
policy, pErr := readBucketPolicy(bucket.Name, objAPI)
|
||||||
if pErr != nil {
|
if pErr != nil {
|
||||||
if !isErrIgnored(pErr, []error{
|
// net.Dial fails for rpc client or any
|
||||||
// net.Dial fails for rpc client or any
|
// other unexpected errors during net.Dial.
|
||||||
// other unexpected errors during net.Dial.
|
if !isErrIgnored(pErr, errDiskNotFound) {
|
||||||
errDiskNotFound,
|
|
||||||
}) {
|
|
||||||
if !isErrBucketPolicyNotFound(pErr) {
|
if !isErrBucketPolicyNotFound(pErr) {
|
||||||
pErrs = append(pErrs, pErr)
|
pErrs = append(pErrs, pErr)
|
||||||
}
|
}
|
||||||
|
@ -120,3 +120,20 @@ func errorsCause(errs []error) []error {
|
|||||||
}
|
}
|
||||||
return cerrs
|
return cerrs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var baseIgnoredErrs = []error{
|
||||||
|
errDiskNotFound,
|
||||||
|
errFaultyDisk,
|
||||||
|
errFaultyRemoteDisk,
|
||||||
|
}
|
||||||
|
|
||||||
|
// isErrIgnored returns whether given error is ignored or not.
|
||||||
|
func isErrIgnored(err error, ignoredErrs ...error) bool {
|
||||||
|
err = errorCause(err)
|
||||||
|
for _, ignoredErr := range ignoredErrs {
|
||||||
|
if ignoredErr == err {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
@ -438,22 +438,15 @@ func removeListenerConfig(bucket string, objAPI ObjectLayer) error {
|
|||||||
|
|
||||||
// Loads both notification and listener config.
|
// Loads both notification and listener config.
|
||||||
func loadNotificationAndListenerConfig(bucketName string, objAPI ObjectLayer) (nCfg *notificationConfig, lCfg []listenerConfig, err error) {
|
func loadNotificationAndListenerConfig(bucketName string, objAPI ObjectLayer) (nCfg *notificationConfig, lCfg []listenerConfig, err error) {
|
||||||
nConfigErrs := []error{
|
|
||||||
// When no previous notification configs were found.
|
|
||||||
errNoSuchNotifications,
|
|
||||||
// net.Dial fails for rpc client or any
|
|
||||||
// other unexpected errors during net.Dial.
|
|
||||||
errDiskNotFound,
|
|
||||||
}
|
|
||||||
// Loads notification config if any.
|
// Loads notification config if any.
|
||||||
nCfg, err = loadNotificationConfig(bucketName, objAPI)
|
nCfg, err = loadNotificationConfig(bucketName, objAPI)
|
||||||
if err != nil && !isErrIgnored(err, nConfigErrs) {
|
if err != nil && !isErrIgnored(err, errDiskNotFound, errNoSuchNotifications) {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loads listener config if any.
|
// Loads listener config if any.
|
||||||
lCfg, err = loadListenerConfig(bucketName, objAPI)
|
lCfg, err = loadListenerConfig(bucketName, objAPI)
|
||||||
if err != nil && !isErrIgnored(err, nConfigErrs) {
|
if err != nil && !isErrIgnored(err, errDiskNotFound, errNoSuchNotifications) {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
return nCfg, lCfg, nil
|
return nCfg, lCfg, nil
|
||||||
|
@ -90,7 +90,7 @@ func (fs fsObjects) listMultipartUploads(bucket, prefix, keyMarker, uploadIDMark
|
|||||||
// For any walk error return right away.
|
// For any walk error return right away.
|
||||||
if walkResult.err != nil {
|
if walkResult.err != nil {
|
||||||
// File not found or Disk not found is a valid case.
|
// File not found or Disk not found is a valid case.
|
||||||
if isErrIgnored(walkResult.err, fsTreeWalkIgnoredErrs) {
|
if isErrIgnored(walkResult.err, fsTreeWalkIgnoredErrs...) {
|
||||||
eof = true
|
eof = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -48,17 +48,6 @@ func init() {
|
|||||||
globalObjLayerMutex = &sync.Mutex{}
|
globalObjLayerMutex = &sync.Mutex{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// isErrIgnored should we ignore this error?, takes a list of errors which can be ignored.
|
|
||||||
func isErrIgnored(err error, ignoredErrs []error) bool {
|
|
||||||
err = errorCause(err)
|
|
||||||
for _, ignoredErr := range ignoredErrs {
|
|
||||||
if ignoredErr == err {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// House keeping code for FS/XL and distributed Minio setup.
|
// House keeping code for FS/XL and distributed Minio setup.
|
||||||
func houseKeeping(storageDisks []StorageAPI) error {
|
func houseKeeping(storageDisks []StorageAPI) error {
|
||||||
var wg = &sync.WaitGroup{}
|
var wg = &sync.WaitGroup{}
|
||||||
@ -83,9 +72,7 @@ func houseKeeping(storageDisks []StorageAPI) error {
|
|||||||
// Cleanup all temp entries upon start.
|
// Cleanup all temp entries upon start.
|
||||||
err := cleanupDir(disk, minioMetaTmpBucket, "")
|
err := cleanupDir(disk, minioMetaTmpBucket, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
switch errorCause(err) {
|
if !isErrIgnored(errorCause(err), errDiskNotFound, errVolumeNotFound, errFileNotFound) {
|
||||||
case errDiskNotFound, errVolumeNotFound, errFileNotFound:
|
|
||||||
default:
|
|
||||||
errs[index] = err
|
errs[index] = err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -196,12 +183,7 @@ func newStorageAPI(ep *url.URL) (storage StorageAPI, err error) {
|
|||||||
return newStorageRPC(ep)
|
return newStorageRPC(ep)
|
||||||
}
|
}
|
||||||
|
|
||||||
var initMetaVolIgnoredErrs = []error{
|
var initMetaVolIgnoredErrs = append(baseIgnoredErrs, errVolumeExists)
|
||||||
errVolumeExists,
|
|
||||||
errDiskNotFound,
|
|
||||||
errFaultyDisk,
|
|
||||||
errFaultyRemoteDisk,
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initializes meta volume on all input storage disks.
|
// Initializes meta volume on all input storage disks.
|
||||||
func initMetaVolume(storageDisks []StorageAPI) error {
|
func initMetaVolume(storageDisks []StorageAPI) error {
|
||||||
@ -227,21 +209,21 @@ func initMetaVolume(storageDisks []StorageAPI) error {
|
|||||||
// Attempt to create `.minio.sys`.
|
// Attempt to create `.minio.sys`.
|
||||||
err := disk.MakeVol(minioMetaBucket)
|
err := disk.MakeVol(minioMetaBucket)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !isErrIgnored(err, initMetaVolIgnoredErrs) {
|
if !isErrIgnored(err, initMetaVolIgnoredErrs...) {
|
||||||
errs[index] = err
|
errs[index] = err
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = disk.MakeVol(minioMetaTmpBucket)
|
err = disk.MakeVol(minioMetaTmpBucket)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !isErrIgnored(err, initMetaVolIgnoredErrs) {
|
if !isErrIgnored(err, initMetaVolIgnoredErrs...) {
|
||||||
errs[index] = err
|
errs[index] = err
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = disk.MakeVol(minioMetaMultipartBucket)
|
err = disk.MakeVol(minioMetaMultipartBucket)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !isErrIgnored(err, initMetaVolIgnoredErrs) {
|
if !isErrIgnored(err, initMetaVolIgnoredErrs...) {
|
||||||
errs[index] = err
|
errs[index] = err
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -133,7 +133,7 @@ func listDirFactory(isLeaf isLeafFunc, treeWalkIgnoredErrs []error, disks ...Sto
|
|||||||
}
|
}
|
||||||
// For any reason disk was deleted or goes offline, continue
|
// For any reason disk was deleted or goes offline, continue
|
||||||
// and list from other disks if possible.
|
// and list from other disks if possible.
|
||||||
if isErrIgnored(err, treeWalkIgnoredErrs) {
|
if isErrIgnored(err, treeWalkIgnoredErrs...) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
@ -21,17 +21,12 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// list all errors that can be ignore in a bucket operation.
|
||||||
|
var bucketOpIgnoredErrs = append(baseIgnoredErrs, errDiskAccessDenied)
|
||||||
|
|
||||||
// list all errors that can be ignored in a bucket metadata operation.
|
// list all errors that can be ignored in a bucket metadata operation.
|
||||||
var bucketMetadataOpIgnoredErrs = append(bucketOpIgnoredErrs, errVolumeNotFound)
|
var bucketMetadataOpIgnoredErrs = append(bucketOpIgnoredErrs, errVolumeNotFound)
|
||||||
|
|
||||||
// list all errors that can be ignore in a bucket operation.
|
|
||||||
var bucketOpIgnoredErrs = []error{
|
|
||||||
errFaultyDisk,
|
|
||||||
errFaultyRemoteDisk,
|
|
||||||
errDiskNotFound,
|
|
||||||
errDiskAccessDenied,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Bucket operations
|
/// Bucket operations
|
||||||
|
|
||||||
// MakeBucket - make a bucket.
|
// MakeBucket - make a bucket.
|
||||||
@ -143,7 +138,7 @@ func (xl xlObjects) getBucketInfo(bucketName string) (bucketInfo BucketInfo, err
|
|||||||
}
|
}
|
||||||
err = traceError(err)
|
err = traceError(err)
|
||||||
// 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...) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
@ -219,7 +214,7 @@ func (xl xlObjects) listBuckets() (bucketsInfo []BucketInfo, err error) {
|
|||||||
return bucketsInfo, nil
|
return bucketsInfo, nil
|
||||||
}
|
}
|
||||||
// Ignore any disks not found.
|
// Ignore any disks not found.
|
||||||
if isErrIgnored(err, bucketMetadataOpIgnoredErrs) {
|
if isErrIgnored(err, bucketMetadataOpIgnoredErrs...) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
@ -62,7 +62,7 @@ func (xl xlObjects) isObject(bucket, prefix string) (ok bool) {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
// Ignore for file not found, disk not found or faulty disk.
|
// Ignore for file not found, disk not found or faulty disk.
|
||||||
if isErrIgnored(err, xlTreeWalkIgnoredErrs) {
|
if isErrIgnored(err, xlTreeWalkIgnoredErrs...) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
errorIf(err, "Unable to stat a file %s/%s/%s", bucket, prefix, xlMetaJSONFile)
|
errorIf(err, "Unable to stat a file %s/%s/%s", bucket, prefix, xlMetaJSONFile)
|
||||||
|
@ -184,7 +184,7 @@ func listBucketNames(storageDisks []StorageAPI) (bucketNames map[string]struct{}
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// Ignore any disks not found.
|
// Ignore any disks not found.
|
||||||
if isErrIgnored(err, bucketMetadataOpIgnoredErrs) {
|
if isErrIgnored(err, bucketMetadataOpIgnoredErrs...) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
@ -206,15 +206,7 @@ func pickValidXLMeta(metaArr []xlMetaV1, modTime time.Time) (xlMetaV1, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// list of all errors that can be ignored in a metadata operation.
|
// list of all errors that can be ignored in a metadata operation.
|
||||||
var objMetadataOpIgnoredErrs = []error{
|
var objMetadataOpIgnoredErrs = append(baseIgnoredErrs, errDiskAccessDenied, errVolumeNotFound, errFileNotFound, errFileAccessDenied)
|
||||||
errDiskNotFound,
|
|
||||||
errDiskAccessDenied,
|
|
||||||
errFaultyDisk,
|
|
||||||
errFaultyRemoteDisk,
|
|
||||||
errVolumeNotFound,
|
|
||||||
errFileAccessDenied,
|
|
||||||
errFileNotFound,
|
|
||||||
}
|
|
||||||
|
|
||||||
// readXLMetaParts - returns the XL Metadata Parts from xl.json of one of the disks picked at random.
|
// readXLMetaParts - returns the XL Metadata Parts from xl.json of one of the disks picked at random.
|
||||||
func (xl xlObjects) readXLMetaParts(bucket, object string) (xlMetaParts []objectPartInfo, err error) {
|
func (xl xlObjects) readXLMetaParts(bucket, object string) (xlMetaParts []objectPartInfo, err error) {
|
||||||
@ -228,7 +220,7 @@ func (xl xlObjects) readXLMetaParts(bucket, object string) (xlMetaParts []object
|
|||||||
}
|
}
|
||||||
// For any reason disk or bucket is not available continue
|
// For any reason disk or bucket is not available continue
|
||||||
// and read from other disks.
|
// and read from other disks.
|
||||||
if isErrIgnored(err, objMetadataOpIgnoredErrs) {
|
if isErrIgnored(err, objMetadataOpIgnoredErrs...) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
@ -250,7 +242,7 @@ func (xl xlObjects) readXLMetaStat(bucket, object string) (xlStat statInfo, xlMe
|
|||||||
}
|
}
|
||||||
// For any reason disk or bucket is not available continue
|
// For any reason disk or bucket is not available continue
|
||||||
// and read from other disks.
|
// and read from other disks.
|
||||||
if isErrIgnored(err, objMetadataOpIgnoredErrs) {
|
if isErrIgnored(err, objMetadataOpIgnoredErrs...) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
@ -166,7 +166,7 @@ func (xl xlObjects) isMultipartUpload(bucket, prefix string) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
// For any reason disk was deleted or goes offline, continue
|
// For any reason disk was deleted or goes offline, continue
|
||||||
if isErrIgnored(err, objMetadataOpIgnoredErrs) {
|
if isErrIgnored(err, objMetadataOpIgnoredErrs...) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
@ -213,7 +213,7 @@ func (xl xlObjects) statPart(bucket, object, uploadID, partName string) (fileInf
|
|||||||
}
|
}
|
||||||
err = traceError(err)
|
err = traceError(err)
|
||||||
// For any reason disk was deleted or goes offline we continue to next disk.
|
// For any reason disk was deleted or goes offline we continue to next disk.
|
||||||
if isErrIgnored(err, objMetadataOpIgnoredErrs) {
|
if isErrIgnored(err, objMetadataOpIgnoredErrs...) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ func (xl xlObjects) listMultipartUploads(bucket, prefix, keyMarker, uploadIDMark
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if isErrIgnored(err, objMetadataOpIgnoredErrs) {
|
if isErrIgnored(err, objMetadataOpIgnoredErrs...) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
@ -110,7 +110,7 @@ func (xl xlObjects) listMultipartUploads(bucket, prefix, keyMarker, uploadIDMark
|
|||||||
// For any walk error return right away.
|
// For any walk error return right away.
|
||||||
if walkResult.err != nil {
|
if walkResult.err != nil {
|
||||||
// File not found or Disk not found is a valid case.
|
// File not found or Disk not found is a valid case.
|
||||||
if isErrIgnored(walkResult.err, xlTreeWalkIgnoredErrs) {
|
if isErrIgnored(walkResult.err, xlTreeWalkIgnoredErrs...) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
return ListMultipartsInfo{}, err
|
return ListMultipartsInfo{}, err
|
||||||
@ -147,14 +147,14 @@ func (xl xlObjects) listMultipartUploads(bucket, prefix, keyMarker, uploadIDMark
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if isErrIgnored(err, objMetadataOpIgnoredErrs) {
|
if isErrIgnored(err, objMetadataOpIgnoredErrs...) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
entryLock.RUnlock()
|
entryLock.RUnlock()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if isErrIgnored(err, xlTreeWalkIgnoredErrs) {
|
if isErrIgnored(err, xlTreeWalkIgnoredErrs...) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
return ListMultipartsInfo{}, err
|
return ListMultipartsInfo{}, err
|
||||||
|
@ -35,7 +35,7 @@ func reduceErrs(errs []error, ignoredErrs []error) (maxCount int, maxErr error)
|
|||||||
errorCounts := make(map[error]int)
|
errorCounts := make(map[error]int)
|
||||||
errs = errorsCause(errs)
|
errs = errorsCause(errs)
|
||||||
for _, err := range errs {
|
for _, err := range errs {
|
||||||
if isErrIgnored(err, ignoredErrs) {
|
if isErrIgnored(err, ignoredErrs...) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
errorCounts[err]++
|
errorCounts[err]++
|
||||||
@ -83,12 +83,7 @@ func reduceWriteQuorumErrs(errs []error, ignoredErrs []error, writeQuorum int) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// List of all errors which are ignored while verifying quorum.
|
// List of all errors which are ignored while verifying quorum.
|
||||||
var quorumIgnoredErrs = []error{
|
var quorumIgnoredErrs = append(baseIgnoredErrs, errDiskAccessDenied)
|
||||||
errFaultyDisk,
|
|
||||||
errFaultyRemoteDisk,
|
|
||||||
errDiskNotFound,
|
|
||||||
errDiskAccessDenied,
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validates if we have quorum based on the errors related to disk only.
|
// Validates if we have quorum based on the errors related to disk only.
|
||||||
// Returns 'true' if we have quorum, 'false' if we don't.
|
// Returns 'true' if we have quorum, 'false' if we don't.
|
||||||
@ -97,7 +92,7 @@ func isDiskQuorum(errs []error, minQuorumCount int) bool {
|
|||||||
errs = errorsCause(errs)
|
errs = errorsCause(errs)
|
||||||
for _, err := range errs {
|
for _, err := range errs {
|
||||||
// Check if the error can be ignored for quorum verification.
|
// Check if the error can be ignored for quorum verification.
|
||||||
if !isErrIgnored(err, quorumIgnoredErrs) {
|
if !isErrIgnored(err, quorumIgnoredErrs...) {
|
||||||
count++
|
count++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,14 +72,7 @@ type xlObjects struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// list of all errors that can be ignored in tree walk operation in XL
|
// list of all errors that can be ignored in tree walk operation in XL
|
||||||
var xlTreeWalkIgnoredErrs = []error{
|
var xlTreeWalkIgnoredErrs = append(baseIgnoredErrs, errDiskAccessDenied, errVolumeNotFound, errFileNotFound)
|
||||||
errFileNotFound,
|
|
||||||
errVolumeNotFound,
|
|
||||||
errDiskNotFound,
|
|
||||||
errDiskAccessDenied,
|
|
||||||
errFaultyDisk,
|
|
||||||
errFaultyRemoteDisk,
|
|
||||||
}
|
|
||||||
|
|
||||||
// newXLObjects - initialize new xl object layer.
|
// newXLObjects - initialize new xl object layer.
|
||||||
func newXLObjects(storageDisks []StorageAPI) (ObjectLayer, error) {
|
func newXLObjects(storageDisks []StorageAPI) (ObjectLayer, error) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user