From 7b14e9b660ce2d93cfc2f481c89c67d0484c40ea Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Thu, 16 Jul 2020 07:30:05 -0700 Subject: [PATCH] fix: diskInfo should check diskID only if disk is online (#10058) closes #10057 --- cmd/background-newdisks-heal-ops.go | 10 +++++++++- cmd/erasure-sets.go | 9 +++++---- cmd/xl-storage-disk-id-check.go | 8 ++++++-- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/cmd/background-newdisks-heal-ops.go b/cmd/background-newdisks-heal-ops.go index 0d1637000..c0132c7f8 100644 --- a/cmd/background-newdisks-heal-ops.go +++ b/cmd/background-newdisks-heal-ops.go @@ -20,10 +20,11 @@ import ( "context" "time" + "github.com/dustin/go-humanize" "github.com/minio/minio/cmd/logger" ) -const defaultMonitorNewDiskInterval = time.Minute * 10 +const defaultMonitorNewDiskInterval = time.Minute * 5 func initLocalDisksAutoHeal(ctx context.Context, objAPI ObjectLayer) { go monitorLocalDisksAndHeal(ctx, objAPI) @@ -83,6 +84,13 @@ func monitorLocalDisksAndHeal(ctx context.Context, objAPI ObjectLayer) { continue } + logger.Info("New unformatted drives detected attempting to heal...") + for i, disks := range localDisksInZoneHeal { + for _, disk := range disks { + logger.Info("Healing disk '%s' on %s zone", disk, humanize.Ordinal(i+1)) + } + } + // Reformat disks bgSeq.sourceCh <- healSource{bucket: SlashSeparator} diff --git a/cmd/erasure-sets.go b/cmd/erasure-sets.go index b4ad91424..3841d411a 100644 --- a/cmd/erasure-sets.go +++ b/cmd/erasure-sets.go @@ -1256,8 +1256,9 @@ func (s *erasureSets) ReloadFormat(ctx context.Context, dryRun bool) (err error) func isTestSetup(infos []DiskInfo, errs []error) bool { rootDiskCount := 0 for i := range errs { - if errs[i] != nil { - // On error it is safer to assume that this is not a test setup. + if errs[i] != nil && errs[i] != errUnformattedDisk { + // On any error which is not unformatted disk + // it is safer to reject healing. return false } if infos[i].RootDisk { @@ -1268,7 +1269,7 @@ func isTestSetup(infos []DiskInfo, errs []error) bool { return rootDiskCount == len(infos) } -func getAllDiskInfos(storageDisks []StorageAPI) ([]DiskInfo, []error) { +func getHealDiskInfos(storageDisks []StorageAPI) ([]DiskInfo, []error) { infos := make([]DiskInfo, len(storageDisks)) g := errgroup.WithNErrs(len(storageDisks)) for index := range storageDisks { @@ -1289,7 +1290,7 @@ func getAllDiskInfos(storageDisks []StorageAPI) ([]DiskInfo, []error) { // Mark root disks as down so as not to heal them. func markRootDisksAsDown(storageDisks []StorageAPI) { - infos, errs := getAllDiskInfos(storageDisks) + infos, errs := getHealDiskInfos(storageDisks) if isTestSetup(infos, errs) { // Allow healing of disks for test setups to help with testing. return diff --git a/cmd/xl-storage-disk-id-check.go b/cmd/xl-storage-disk-id-check.go index 496ebee93..7b98a2355 100644 --- a/cmd/xl-storage-disk-id-check.go +++ b/cmd/xl-storage-disk-id-check.go @@ -89,8 +89,12 @@ func (p *xlStorageDiskIDCheck) DiskInfo() (info DiskInfo, err error) { if err != nil { return info, err } - if p.diskID != info.ID { - return info, errDiskNotFound + // check cached diskID against backend + // only if its non-empty. + if p.diskID != "" { + if p.diskID != info.ID { + return info, errDiskNotFound + } } return info, nil }