mirror of
https://github.com/minio/minio.git
synced 2024-12-24 06:05:55 -05:00
Add a isErr
function to check for errs.
DisksInfo() should handle collection of some base errors as offlineDisks.
This commit is contained in:
parent
6d10f4c19a
commit
7bbb532b4b
@ -121,12 +121,15 @@ func errorsCause(errs []error) []error {
|
||||
return cerrs
|
||||
}
|
||||
|
||||
var baseIgnoredErrs = []error{
|
||||
// Collection of basic errors.
|
||||
var baseErrs = []error{
|
||||
errDiskNotFound,
|
||||
errFaultyDisk,
|
||||
errFaultyRemoteDisk,
|
||||
}
|
||||
|
||||
var baseIgnoredErrs = baseErrs
|
||||
|
||||
// isErrIgnored returns whether given error is ignored or not.
|
||||
func isErrIgnored(err error, ignoredErrs ...error) bool {
|
||||
err = errorCause(err)
|
||||
@ -137,3 +140,14 @@ func isErrIgnored(err error, ignoredErrs ...error) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// isErr returns whether given error is exact error.
|
||||
func isErr(err error, errs ...error) bool {
|
||||
err = errorCause(err)
|
||||
for _, exactErr := range errs {
|
||||
if err == exactErr {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
@ -169,10 +169,10 @@ func getDisksInfo(disks []StorageAPI) (disksInfo []disk.Info, onlineDisks int, o
|
||||
info, err := storageDisk.DiskInfo()
|
||||
if err != nil {
|
||||
errorIf(err, "Unable to fetch disk info for %#v", storageDisk)
|
||||
if err == errDiskNotFound {
|
||||
if isErr(err, baseErrs...) {
|
||||
offlineDisks++
|
||||
continue
|
||||
}
|
||||
continue
|
||||
}
|
||||
onlineDisks++
|
||||
disksInfo[i] = info
|
||||
|
Loading…
Reference in New Issue
Block a user