mirror of
https://github.com/minio/minio.git
synced 2025-04-18 17:55:28 -04:00
Quit initializing disks process when term signal is invoked (#3163)
This commit is contained in:
parent
d9674f7524
commit
e6965ca066
@ -17,6 +17,7 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"net/url"
|
"net/url"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -204,63 +205,68 @@ func retryFormattingDisks(firstDisk bool, endpoints []*url.URL, storageDisks []S
|
|||||||
defer close(doneCh)
|
defer close(doneCh)
|
||||||
|
|
||||||
// Wait on the jitter retry loop.
|
// Wait on the jitter retry loop.
|
||||||
for retryCounter := range newRetryTimer(time.Second, time.Second*30, MaxJitter, doneCh) {
|
retryTimerCh := newRetryTimer(time.Second, time.Second*30, MaxJitter, doneCh)
|
||||||
// Attempt to load all `format.json`.
|
for {
|
||||||
formatConfigs, sErrs := loadAllFormats(storageDisks)
|
select {
|
||||||
if retryCounter > 5 {
|
case retryCounter := <-retryTimerCh:
|
||||||
for i, e := range sErrs {
|
// Attempt to load all `format.json`.
|
||||||
if e == errDiskNotFound {
|
formatConfigs, sErrs := loadAllFormats(storageDisks)
|
||||||
console.Printf("%s still unreachable.\n", storageDisks[i])
|
if retryCounter > 5 {
|
||||||
|
for i, e := range sErrs {
|
||||||
|
if e == errDiskNotFound {
|
||||||
|
console.Printf("%s still unreachable.\n", storageDisks[i])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Check if this is a XL or distributed XL, anything > 1 is considered XL backend.
|
||||||
|
if len(formatConfigs) > 1 {
|
||||||
|
switch prepForInitXL(firstDisk, sErrs, len(storageDisks)) {
|
||||||
|
case Abort:
|
||||||
|
return errCorruptedFormat
|
||||||
|
case FormatDisks:
|
||||||
|
console.Eraseline()
|
||||||
|
printFormatMsg(endpoints, storageDisks, printOnceFn())
|
||||||
|
return initFormatXL(storageDisks)
|
||||||
|
case InitObjectLayer:
|
||||||
|
console.Eraseline()
|
||||||
|
// Validate formats load before proceeding forward.
|
||||||
|
err := genericFormatCheck(formatConfigs, sErrs)
|
||||||
|
if err == nil {
|
||||||
|
printRegularMsg(endpoints, storageDisks, printOnceFn())
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
case WaitForHeal:
|
||||||
|
// Validate formats load before proceeding forward.
|
||||||
|
err := genericFormatCheck(formatConfigs, sErrs)
|
||||||
|
if err == nil {
|
||||||
|
printHealMsg(firstEndpoint.String(), storageDisks, printOnceFn())
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
case WaitForQuorum:
|
||||||
|
console.Printf(
|
||||||
|
"Initializing data volume. Waiting for minimum %d servers to come online.\n",
|
||||||
|
len(storageDisks)/2+1,
|
||||||
|
)
|
||||||
|
case WaitForConfig:
|
||||||
|
// Print configuration errors.
|
||||||
|
printConfigErrMsg(storageDisks, sErrs, printOnceFn())
|
||||||
|
case WaitForAll:
|
||||||
|
console.Println("Initializing data volume for first time. Waiting for other servers to come online.")
|
||||||
|
case WaitForFormatting:
|
||||||
|
console.Println("Initializing data volume for first time. Waiting for first server to come online.")
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
} // else We have FS backend now. Check fs format as well now.
|
||||||
|
if isFormatFound(formatConfigs) {
|
||||||
|
console.Eraseline()
|
||||||
|
// Validate formats load before proceeding forward.
|
||||||
|
return genericFormatCheck(formatConfigs, sErrs)
|
||||||
|
} // else initialize the format for FS.
|
||||||
|
return initFormatFS(storageDisks[0])
|
||||||
|
case <-globalServiceDoneCh:
|
||||||
|
return errors.New("Initializing data volumes gracefully stopped.")
|
||||||
}
|
}
|
||||||
// Check if this is a XL or distributed XL, anything > 1 is considered XL backend.
|
}
|
||||||
if len(formatConfigs) > 1 {
|
|
||||||
switch prepForInitXL(firstDisk, sErrs, len(storageDisks)) {
|
|
||||||
case Abort:
|
|
||||||
return errCorruptedFormat
|
|
||||||
case FormatDisks:
|
|
||||||
console.Eraseline()
|
|
||||||
printFormatMsg(endpoints, storageDisks, printOnceFn())
|
|
||||||
return initFormatXL(storageDisks)
|
|
||||||
case InitObjectLayer:
|
|
||||||
console.Eraseline()
|
|
||||||
// Validate formats load before proceeding forward.
|
|
||||||
err := genericFormatCheck(formatConfigs, sErrs)
|
|
||||||
if err == nil {
|
|
||||||
printRegularMsg(endpoints, storageDisks, printOnceFn())
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
case WaitForHeal:
|
|
||||||
// Validate formats load before proceeding forward.
|
|
||||||
err := genericFormatCheck(formatConfigs, sErrs)
|
|
||||||
if err == nil {
|
|
||||||
printHealMsg(firstEndpoint.String(), storageDisks, printOnceFn())
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
case WaitForQuorum:
|
|
||||||
console.Printf(
|
|
||||||
"Initializing data volume. Waiting for minimum %d servers to come online.\n",
|
|
||||||
len(storageDisks)/2+1,
|
|
||||||
)
|
|
||||||
case WaitForConfig:
|
|
||||||
// Print configuration errors.
|
|
||||||
printConfigErrMsg(storageDisks, sErrs, printOnceFn())
|
|
||||||
case WaitForAll:
|
|
||||||
console.Println("Initializing data volume for first time. Waiting for other servers to come online.")
|
|
||||||
case WaitForFormatting:
|
|
||||||
console.Println("Initializing data volume for first time. Waiting for first server to come online.")
|
|
||||||
}
|
|
||||||
continue
|
|
||||||
} // else We have FS backend now. Check fs format as well now.
|
|
||||||
if isFormatFound(formatConfigs) {
|
|
||||||
console.Eraseline()
|
|
||||||
// Validate formats load before proceeding forward.
|
|
||||||
return genericFormatCheck(formatConfigs, sErrs)
|
|
||||||
} // else initialize the format for FS.
|
|
||||||
return initFormatFS(storageDisks[0])
|
|
||||||
} // Return here.
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize storage disks based on input arguments.
|
// Initialize storage disks based on input arguments.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user