From e3fbac9e24f07d4c0b068c3512301cab85b06923 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Sun, 11 Feb 2024 23:21:56 -0800 Subject: [PATCH] do not have to use the same distributionAlgo as first pool (#19031) when we expand via pools, there is no reason to stick with the same distributionAlgo as the rest. Since the algo only makes sense with-in a pool not across pools. This allows for newer pools to use newer codepaths to avoid legacy file lookups when they have a pre-existing deployment from 2019, they can expand their new pool to be of a newer distribution format, allowing the pool to be more performant. --- cmd/api-errors.go | 2 +- cmd/erasure-server-pool.go | 16 ++++------------ cmd/erasure-sets_test.go | 6 +++--- cmd/format-erasure.go | 5 +---- cmd/prepare-storage.go | 10 +++++----- 5 files changed, 14 insertions(+), 25 deletions(-) diff --git a/cmd/api-errors.go b/cmd/api-errors.go index e387ea6e5..102638ab4 100644 --- a/cmd/api-errors.go +++ b/cmd/api-errors.go @@ -2351,7 +2351,7 @@ func toAPIErrorCode(ctx context.Context, err error) (apiErr APIErrorCode) { case dns.ErrBucketConflict: apiErr = ErrBucketAlreadyExists default: - if strings.Contains(err.Error(), "requested declared a Content-Length") { + if strings.Contains(err.Error(), "request declared a Content-Length") { apiErr = ErrIncompleteBody } else { apiErr = ErrInternalError diff --git a/cmd/erasure-server-pool.go b/cmd/erasure-server-pool.go index 4dc64ac5c..c9ba0bee0 100644 --- a/cmd/erasure-server-pool.go +++ b/cmd/erasure-server-pool.go @@ -72,15 +72,15 @@ func (z *erasureServerPools) SinglePool() bool { func newErasureServerPools(ctx context.Context, endpointServerPools EndpointServerPools) (ObjectLayer, error) { var ( deploymentID string - distributionAlgo string commonParityDrives int err error formats = make([]*formatErasureV3, len(endpointServerPools)) storageDisks = make([][]StorageAPI, len(endpointServerPools)) z = &erasureServerPools{ - serverPools: make([]*erasureSets, len(endpointServerPools)), - s3Peer: NewS3PeerSys(endpointServerPools), + serverPools: make([]*erasureSets, len(endpointServerPools)), + s3Peer: NewS3PeerSys(endpointServerPools), + distributionAlgo: formatErasureVersionV3DistributionAlgoV3, } ) @@ -126,7 +126,7 @@ func newErasureServerPools(ctx context.Context, endpointServerPools EndpointServ bootstrapTrace("waitForFormatErasure: loading disks", func() { storageDisks[i], formats[i], err = waitForFormatErasure(local, ep.Endpoints, i+1, - ep.SetCount, ep.DrivesPerSet, deploymentID, distributionAlgo) + ep.SetCount, ep.DrivesPerSet, deploymentID) }) if err != nil { return nil, err @@ -137,10 +137,6 @@ func newErasureServerPools(ctx context.Context, endpointServerPools EndpointServ deploymentID = formats[i].ID } - if distributionAlgo == "" { - distributionAlgo = formats[i].Erasure.DistributionAlgo - } - // Validate if users brought different DeploymentID pools. if deploymentID != formats[i].ID { return nil, fmt.Errorf("all pools must have same deployment ID - expected %s, got %s for pool(%s)", deploymentID, formats[i].ID, humanize.Ordinal(i+1)) @@ -157,10 +153,6 @@ func newErasureServerPools(ctx context.Context, endpointServerPools EndpointServ z.deploymentID = uuid.MustParse(deploymentID) } - if distributionAlgo != "" && z.distributionAlgo == "" { - z.distributionAlgo = distributionAlgo - } - for _, storageDisk := range storageDisks[i] { if storageDisk != nil && storageDisk.IsLocal() { localDrives = append(localDrives, storageDisk) diff --git a/cmd/erasure-sets_test.go b/cmd/erasure-sets_test.go index 1e411d6c9..f8cb16b7d 100644 --- a/cmd/erasure-sets_test.go +++ b/cmd/erasure-sets_test.go @@ -174,18 +174,18 @@ func TestNewErasureSets(t *testing.T) { } endpoints := mustGetNewEndpoints(0, 16, erasureDisks...) - _, _, err := waitForFormatErasure(true, endpoints, 1, 0, 16, "", "") + _, _, err := waitForFormatErasure(true, endpoints, 1, 0, 16, "") if err != errInvalidArgument { t.Fatalf("Expecting error, got %s", err) } - _, _, err = waitForFormatErasure(true, nil, 1, 1, 16, "", "") + _, _, err = waitForFormatErasure(true, nil, 1, 1, 16, "") if err != errInvalidArgument { t.Fatalf("Expecting error, got %s", err) } // Initializes all erasure disks - storageDisks, format, err := waitForFormatErasure(true, endpoints, 1, 1, 16, "", "") + storageDisks, format, err := waitForFormatErasure(true, endpoints, 1, 1, 16, "") if err != nil { t.Fatalf("Unable to format drives for erasure, %s", err) } diff --git a/cmd/format-erasure.go b/cmd/format-erasure.go index 7eba27993..41a7a5366 100644 --- a/cmd/format-erasure.go +++ b/cmd/format-erasure.go @@ -761,7 +761,7 @@ func fixFormatErasureV3(storageDisks []StorageAPI, endpoints Endpoints, formats } // initFormatErasure - save Erasure format configuration on all disks. -func initFormatErasure(ctx context.Context, storageDisks []StorageAPI, setCount, setDriveCount int, deploymentID, distributionAlgo string, sErrs []error) (*formatErasureV3, error) { +func initFormatErasure(ctx context.Context, storageDisks []StorageAPI, setCount, setDriveCount int, deploymentID string, sErrs []error) (*formatErasureV3, error) { format := newFormatErasureV3(setCount, setDriveCount) formats := make([]*formatErasureV3, len(storageDisks)) wantAtMost, err := ecDrivesNoConfig(setDriveCount) @@ -778,9 +778,6 @@ func initFormatErasure(ctx context.Context, storageDisks []StorageAPI, setCount, } newFormat := format.Clone() newFormat.Erasure.This = format.Erasure.Sets[i][j] - if distributionAlgo != "" { - newFormat.Erasure.DistributionAlgo = distributionAlgo - } if deploymentID != "" { newFormat.ID = deploymentID } diff --git a/cmd/prepare-storage.go b/cmd/prepare-storage.go index c2b5b5021..beec2ebcc 100644 --- a/cmd/prepare-storage.go +++ b/cmd/prepare-storage.go @@ -154,7 +154,7 @@ func isServerResolvable(endpoint Endpoint, timeout time.Duration) error { // connect to list of endpoints and load all Erasure disk formats, validate the formats are correct // and are in quorum, if no formats are found attempt to initialize all of them for the first // time. additionally make sure to close all the disks used in this attempt. -func connectLoadInitFormats(verboseLogging bool, firstDisk bool, endpoints Endpoints, poolCount, setCount, setDriveCount int, deploymentID, distributionAlgo string) (storageDisks []StorageAPI, format *formatErasureV3, err error) { +func connectLoadInitFormats(verboseLogging bool, firstDisk bool, endpoints Endpoints, poolCount, setCount, setDriveCount int, deploymentID string) (storageDisks []StorageAPI, format *formatErasureV3, err error) { // Initialize all storage disks storageDisks, errs := initStorageDisksWithErrors(endpoints, storageOpts{cleanUp: true, healthCheck: true}) @@ -221,7 +221,7 @@ func connectLoadInitFormats(verboseLogging bool, firstDisk bool, endpoints Endpo humanize.Ordinal(poolCount), setCount, setDriveCount) // Initialize erasure code format on disks - format, err = initFormatErasure(GlobalContext, storageDisks, setCount, setDriveCount, deploymentID, distributionAlgo, sErrs) + format, err = initFormatErasure(GlobalContext, storageDisks, setCount, setDriveCount, deploymentID, sErrs) if err != nil { return nil, nil, err } @@ -260,7 +260,7 @@ func connectLoadInitFormats(verboseLogging bool, firstDisk bool, endpoints Endpo } // Format disks before initialization of object layer. -func waitForFormatErasure(firstDisk bool, endpoints Endpoints, poolCount, setCount, setDriveCount int, deploymentID, distributionAlgo string) ([]StorageAPI, *formatErasureV3, error) { +func waitForFormatErasure(firstDisk bool, endpoints Endpoints, poolCount, setCount, setDriveCount int, deploymentID string) ([]StorageAPI, *formatErasureV3, error) { if len(endpoints) == 0 || setCount == 0 || setDriveCount == 0 { return nil, nil, errInvalidArgument } @@ -277,7 +277,7 @@ func waitForFormatErasure(firstDisk bool, endpoints Endpoints, poolCount, setCou verbose bool ) - storageDisks, format, err := connectLoadInitFormats(verbose, firstDisk, endpoints, poolCount, setCount, setDriveCount, deploymentID, distributionAlgo) + storageDisks, format, err := connectLoadInitFormats(verbose, firstDisk, endpoints, poolCount, setCount, setDriveCount, deploymentID) if err == nil { return storageDisks, format, nil } @@ -295,7 +295,7 @@ func waitForFormatErasure(firstDisk bool, endpoints Endpoints, poolCount, setCou tries = 1 } - storageDisks, format, err := connectLoadInitFormats(verbose, firstDisk, endpoints, poolCount, setCount, setDriveCount, deploymentID, distributionAlgo) + storageDisks, format, err := connectLoadInitFormats(verbose, firstDisk, endpoints, poolCount, setCount, setDriveCount, deploymentID) if err == nil { return storageDisks, format, nil }