From b976521c83f41b82774f50dc16397f02fc5110b7 Mon Sep 17 00:00:00 2001 From: Praveen raj Mani Date: Sat, 3 Aug 2019 00:47:26 +0530 Subject: [PATCH] Ignore faulty disks in xl-sets Storage info (#7878) --- cmd/format-xl.go | 16 ++++++++++++++++ cmd/xl-sets.go | 24 +++++++++++++++--------- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/cmd/format-xl.go b/cmd/format-xl.go index 447752292..4c6f3a998 100644 --- a/cmd/format-xl.go +++ b/cmd/format-xl.go @@ -698,6 +698,22 @@ func initStorageDisks(endpoints EndpointList) ([]StorageAPI, error) { return storageDisks, nil } +// Runs through the faulty disks and record their errors. +func initDisksWithErrors(endpoints EndpointList) ([]StorageAPI, []error) { + storageDisks := make([]StorageAPI, len(endpoints)) + var dErrs = make([]error, len(storageDisks)) + for index, endpoint := range endpoints { + storage, err := newStorageAPI(endpoint) + if err != nil { + logger.LogIf(context.Background(), err) + dErrs[index] = err + continue + } + storageDisks[index] = storage + } + return storageDisks, dErrs +} + // formatXLV3ThisEmpty - find out if '.This' field is empty // in any of the input `formats`, if yes return true. func formatXLV3ThisEmpty(formats []*formatXLV3) bool { diff --git a/cmd/xl-sets.go b/cmd/xl-sets.go index 780a743df..0ee86434f 100644 --- a/cmd/xl-sets.go +++ b/cmd/xl-sets.go @@ -327,15 +327,22 @@ func (s *xlSets) StorageInfo(ctx context.Context) StorageInfo { storageInfo.Backend.Sets[i] = make([]madmin.DriveInfo, s.drivesPerSet) } - storageDisks, err := initStorageDisks(s.endpoints) - if err != nil { - return storageInfo - } + storageDisks, dErrs := initDisksWithErrors(s.endpoints) defer closeStorageDisks(storageDisks) formats, sErrs := loadFormatXLAll(storageDisks) - drivesInfo := formatsToDrivesInfo(s.endpoints, formats, sErrs) + combineStorageErrors := func(diskErrs []error, storageErrs []error) []error { + for index, err := range diskErrs { + if err != nil { + storageErrs[index] = err + } + } + return storageErrs + } + + errs := combineStorageErrors(dErrs, sErrs) + drivesInfo := formatsToDrivesInfo(s.endpoints, formats, errs) refFormat, err := getFormatXLInQuorum(formats) if err != nil { // Ignore errors here, since this call cannot do anything at @@ -356,7 +363,6 @@ func (s *xlSets) StorageInfo(ctx context.Context) StorageInfo { } } } - // fill all the offline, missing endpoints as well. for _, drive := range drivesInfo { if drive.UUID == "" { @@ -1250,17 +1256,17 @@ func formatsToDrivesInfo(endpoints EndpointList, formats []*formatXLV3, sErrs [] Endpoint: drive, State: madmin.DriveStateMissing, }) - case sErrs[i] == errCorruptedFormat: + case sErrs[i] == errDiskNotFound: beforeDrives = append(beforeDrives, madmin.DriveInfo{ UUID: "", Endpoint: drive, - State: madmin.DriveStateCorrupt, + State: madmin.DriveStateOffline, }) default: beforeDrives = append(beforeDrives, madmin.DriveInfo{ UUID: "", Endpoint: drive, - State: madmin.DriveStateOffline, + State: madmin.DriveStateCorrupt, }) } }