From 23e46f9dba458cefb239b148ae0322739e003ae3 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Fri, 17 Jan 2020 15:39:07 -0800 Subject: [PATCH] log formatting only the first time (#8846) --- cmd/admin-handlers_test.go | 2 +- cmd/prepare-storage.go | 9 ++++++--- cmd/test-utils_test.go | 2 +- cmd/xl-sets_test.go | 6 +++--- cmd/xl-zones.go | 4 +--- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/cmd/admin-handlers_test.go b/cmd/admin-handlers_test.go index 8e759ece0..d801f0ec5 100644 --- a/cmd/admin-handlers_test.go +++ b/cmd/admin-handlers_test.go @@ -109,7 +109,7 @@ func initTestXLObjLayer() (ObjectLayer, []string, error) { return nil, nil, err } endpoints := mustGetNewEndpoints(xlDirs...) - format, err := waitForFormatXL(true, endpoints, 1, 16, "") + format, err := waitForFormatXL(true, endpoints, 1, 1, 16, "") if err != nil { removeRoots(xlDirs) return nil, nil, err diff --git a/cmd/prepare-storage.go b/cmd/prepare-storage.go index b862826cd..7aac82e13 100644 --- a/cmd/prepare-storage.go +++ b/cmd/prepare-storage.go @@ -220,7 +220,7 @@ func IsServerResolvable(endpoint Endpoint) error { // connect to list of endpoints and load all XL 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(retryCount int, firstDisk bool, endpoints Endpoints, setCount, drivesPerSet int, deploymentID string) (*formatXLV3, error) { +func connectLoadInitFormats(retryCount int, firstDisk bool, endpoints Endpoints, zoneCount, setCount, drivesPerSet int, deploymentID string) (*formatXLV3, error) { // Initialize all storage disks storageDisks, errs := initStorageDisksWithErrors(endpoints) defer closeStorageDisks(storageDisks) @@ -256,6 +256,9 @@ func connectLoadInitFormats(retryCount int, firstDisk bool, endpoints Endpoints, // All disks report unformatted we should initialized everyone. if shouldInitXLDisks(sErrs) && firstDisk { + logger.Info("Formatting %v zone, %v set(s), %v drives per set.", + zoneCount, setCount, drivesPerSet) + // Initialize erasure code format on disks format, err := initFormatXL(context.Background(), storageDisks, setCount, drivesPerSet, deploymentID) if err != nil { @@ -333,7 +336,7 @@ func connectLoadInitFormats(retryCount int, firstDisk bool, endpoints Endpoints, } // Format disks before initialization of object layer. -func waitForFormatXL(firstDisk bool, endpoints Endpoints, setCount, drivesPerSet int, deploymentID string) (format *formatXLV3, err error) { +func waitForFormatXL(firstDisk bool, endpoints Endpoints, zoneCount, setCount, drivesPerSet int, deploymentID string) (format *formatXLV3, err error) { if len(endpoints) == 0 || setCount == 0 || drivesPerSet == 0 { return nil, errInvalidArgument } @@ -360,7 +363,7 @@ func waitForFormatXL(firstDisk bool, endpoints Endpoints, setCount, drivesPerSet for { select { case <-ticker.C: - format, err := connectLoadInitFormats(tries, firstDisk, endpoints, setCount, drivesPerSet, deploymentID) + format, err := connectLoadInitFormats(tries, firstDisk, endpoints, zoneCount, setCount, drivesPerSet, deploymentID) if err != nil { tries++ switch err { diff --git a/cmd/test-utils_test.go b/cmd/test-utils_test.go index 89161c339..0ac27e296 100644 --- a/cmd/test-utils_test.go +++ b/cmd/test-utils_test.go @@ -193,7 +193,7 @@ func prepareXLSets32() (ObjectLayer, []string, error) { endpoints := append(endpoints1, endpoints2...) fsDirs := append(fsDirs1, fsDirs2...) - format, err := waitForFormatXL(true, endpoints, 2, 16, "") + format, err := waitForFormatXL(true, endpoints, 1, 2, 16, "") if err != nil { removeRoots(fsDirs) return nil, nil, err diff --git a/cmd/xl-sets_test.go b/cmd/xl-sets_test.go index b4e4465ea..a07b22ed1 100644 --- a/cmd/xl-sets_test.go +++ b/cmd/xl-sets_test.go @@ -76,18 +76,18 @@ func TestNewXLSets(t *testing.T) { } endpoints := mustGetNewEndpoints(erasureDisks...) - _, err := waitForFormatXL(true, endpoints, 0, 16, "") + _, err := waitForFormatXL(true, endpoints, 1, 0, 16, "") if err != errInvalidArgument { t.Fatalf("Expecting error, got %s", err) } - _, err = waitForFormatXL(true, nil, 1, 16, "") + _, err = waitForFormatXL(true, nil, 1, 1, 16, "") if err != errInvalidArgument { t.Fatalf("Expecting error, got %s", err) } // Initializes all erasure disks - format, err := waitForFormatXL(true, endpoints, 1, 16, "") + format, err := waitForFormatXL(true, endpoints, 1, 1, 16, "") if err != nil { t.Fatalf("Unable to format disks for erasure, %s", err) } diff --git a/cmd/xl-zones.go b/cmd/xl-zones.go index 7215f36ac..ac8259867 100644 --- a/cmd/xl-zones.go +++ b/cmd/xl-zones.go @@ -62,9 +62,7 @@ func newXLZones(endpointZones EndpointZones) (ObjectLayer, error) { ) local := endpointZones.FirstLocal() for i, ep := range endpointZones { - logger.Info("Formatting %v zone, %v set(s), %v drives per set.", - i+1, ep.SetCount, ep.DrivesPerSet) - formats[i], err = waitForFormatXL(local, ep.Endpoints, + formats[i], err = waitForFormatXL(local, ep.Endpoints, i+1, ep.SetCount, ep.DrivesPerSet, deploymentID) if err != nil { return nil, err