Add a `isErr` function to check for errs.

DisksInfo() should handle collection of some
base errors as offlineDisks.
master
Harshavardhana 8 years ago
parent 6d10f4c19a
commit 7bbb532b4b
  1. 16
      cmd/errors.go
  2. 4
      cmd/xl-v1.go

@ -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…
Cancel
Save