From 5996c8c4d5551941fc2d844f7f996d488ff501b1 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Mon, 6 Feb 2023 09:26:09 -0800 Subject: [PATCH] feat: allow offline disks on a fresh start (#16541) --- cmd/format-erasure.go | 44 +++++++++---------- cmd/prepare-storage.go | 22 ++++------ .../identity/openid/provider/provider.go | 2 + 3 files changed, 30 insertions(+), 38 deletions(-) diff --git a/cmd/format-erasure.go b/cmd/format-erasure.go index 4540497a9..d535039b8 100644 --- a/cmd/format-erasure.go +++ b/cmd/format-erasure.go @@ -304,11 +304,6 @@ func countErrs(errs []error, err error) int { return i } -// Does all errors indicate we need to initialize all disks?. -func shouldInitErasureDisks(errs []error) bool { - return countErrs(errs, errUnformattedDisk) == len(errs) -} - // Check if unformatted disks are equal to write quorum. func quorumUnformattedDisks(errs []error) bool { return countErrs(errs, errUnformattedDisk) >= (len(errs)/2)+1 @@ -750,6 +745,9 @@ func initFormatErasure(ctx context.Context, storageDisks []StorageAPI, setCount, hostCount := make(map[string]int, setDriveCount) for j := 0; j < setDriveCount; j++ { disk := storageDisks[i*setDriveCount+j] + if disk == nil { + continue + } newFormat := format.Clone() newFormat.Erasure.This = format.Erasure.Sets[i][j] if distributionAlgo != "" { @@ -761,26 +759,24 @@ func initFormatErasure(ctx context.Context, storageDisks []StorageAPI, setCount, hostCount[disk.Hostname()]++ formats[i*setDriveCount+j] = newFormat } - if len(hostCount) > 0 { - var once sync.Once - for host, count := range hostCount { - if count > wantAtMost { - if host == "" { - host = "local" - } - once.Do(func() { - if len(hostCount) == 1 { - return - } - logger.Info(" * Set %v:", i+1) - for j := 0; j < setDriveCount; j++ { - disk := storageDisks[i*setDriveCount+j] - logger.Info(" - Drive: %s", disk.String()) - } - }) - logger.Info(color.Yellow("WARNING:")+" Host %v has more than %v drives of set. "+ - "A host failure will result in data becoming unavailable.", host, wantAtMost) + var once sync.Once + for host, count := range hostCount { + if count > wantAtMost { + if host == "" { + host = "local" } + once.Do(func() { + if len(hostCount) == 1 { + return + } + logger.Info(" * Set %v:", i+1) + for j := 0; j < setDriveCount; j++ { + disk := storageDisks[i*setDriveCount+j] + logger.Info(" - Drive: %s", disk.String()) + } + }) + logger.Info(color.Yellow("WARNING:")+" Host %v has more than %v drives of set. "+ + "A host failure will result in data becoming unavailable.", host, wantAtMost) } } } diff --git a/cmd/prepare-storage.go b/cmd/prepare-storage.go index 510ccd177..0b6c5dd2f 100644 --- a/cmd/prepare-storage.go +++ b/cmd/prepare-storage.go @@ -198,8 +198,15 @@ func connectLoadInitFormats(verboseLogging bool, firstDisk bool, endpoints Endpo return nil, nil, err } + // Return error when quorum unformatted disks - indicating we are + // waiting for first server to be online. + unformattedDisks := quorumUnformattedDisks(sErrs) + if unformattedDisks && !firstDisk { + return nil, nil, errNotFirstDisk + } + // All disks report unformatted we should initialized everyone. - if shouldInitErasureDisks(sErrs) && firstDisk { + if unformattedDisks && firstDisk { logger.Info("Formatting %s pool, %v set(s), %v drives per set.", humanize.Ordinal(poolCount), setCount, setDriveCount) @@ -215,19 +222,6 @@ func connectLoadInitFormats(verboseLogging bool, firstDisk bool, endpoints Endpo return storageDisks, format, nil } - // Return error when quorum unformatted disks - indicating we are - // waiting for first server to be online. - unformattedDisks := quorumUnformattedDisks(sErrs) - if unformattedDisks && !firstDisk { - return nil, nil, errNotFirstDisk - } - - // Return error when quorum unformatted disks but waiting for rest - // of the servers to be online. - if unformattedDisks && firstDisk { - return nil, nil, errFirstDiskWait - } - // Mark all root disks down markRootDisksAsDown(storageDisks, sErrs) diff --git a/internal/config/identity/openid/provider/provider.go b/internal/config/identity/openid/provider/provider.go index 43a141e5d..b4ed28d20 100644 --- a/internal/config/identity/openid/provider/provider.go +++ b/internal/config/identity/openid/provider/provider.go @@ -21,6 +21,8 @@ import "errors" // DiscoveryDoc - parses the output from openid-configuration // for example https://accounts.google.com/.well-known/openid-configuration +// +//nolint:unused type DiscoveryDoc struct { Issuer string `json:"issuer,omitempty"` AuthEndpoint string `json:"authorization_endpoint,omitempty"`