diff --git a/cmd/prepare-storage.go b/cmd/prepare-storage.go index 54c4f85e0..d62e4e957 100644 --- a/cmd/prepare-storage.go +++ b/cmd/prepare-storage.go @@ -173,7 +173,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(retryCount int, 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, distributionAlgo string) (storageDisks []StorageAPI, format *formatErasureV3, err error) { // Initialize all storage disks storageDisks, errs := initStorageDisksWithErrors(endpoints) @@ -185,7 +185,7 @@ func connectLoadInitFormats(retryCount int, firstDisk bool, endpoints Endpoints, for i, err := range errs { if err != nil { - if err == errDiskNotFound && retryCount >= 10 { + if err == errDiskNotFound && verboseLogging { logger.Error("Unable to connect to %s: %v", endpoints[i], isServerResolvable(endpoints[i], time.Second)) } else { logger.Error("Unable to use the drive %s: %v", endpoints[i], err) @@ -202,7 +202,7 @@ func connectLoadInitFormats(retryCount int, firstDisk bool, endpoints Endpoints, // Check if we have for i, sErr := range sErrs { // print the error, nonetheless, which is perhaps unhandled - if sErr != errUnformattedDisk && sErr != errDiskNotFound && retryCount >= 10 { + if sErr != errUnformattedDisk && sErr != errDiskNotFound && verboseLogging { if sErr != nil { logger.Error("Unable to read 'format.json' from %s: %v\n", endpoints[i], sErr) } @@ -307,7 +307,8 @@ func waitForFormatErasure(firstDisk bool, endpoints Endpoints, poolCount, setCou } var tries int - storageDisks, format, err := connectLoadInitFormats(tries, firstDisk, endpoints, poolCount, setCount, setDriveCount, deploymentID, distributionAlgo) + var verboseLogging bool + storageDisks, format, err := connectLoadInitFormats(verboseLogging, firstDisk, endpoints, poolCount, setCount, setDriveCount, deploymentID, distributionAlgo) if err == nil { return storageDisks, format, nil } @@ -321,12 +322,13 @@ func waitForFormatErasure(firstDisk bool, endpoints Endpoints, poolCount, setCou for { select { case <-ticker.C: - if tries == 10 { - // Reset the tries count such that we log only for every 10 retries. + // Only log once every 10 iterations, then reset the tries count. + verboseLogging = tries >= 10 + if verboseLogging { tries = 1 } - storageDisks, format, err := connectLoadInitFormats(tries, firstDisk, endpoints, poolCount, setCount, setDriveCount, deploymentID, distributionAlgo) + storageDisks, format, err := connectLoadInitFormats(verboseLogging, firstDisk, endpoints, poolCount, setCount, setDriveCount, deploymentID, distributionAlgo) if err != nil { tries++ switch err {