mirror of
https://github.com/minio/minio.git
synced 2025-11-29 05:19:03 -05:00
Fix preInit logic when mixed disk situations exist. (#4904)
When servers are started simultaneously across multiple nodes or simulating a local setup, it can happen such that one of the servers in setup reaches a following situation where it observes - Some servers are formatted - Some servers are unformatted - Some servers are offline Current state machine doesn't handle this correctly, to fix this situation where we have unformatted, formatted and disks offline we do not decisively know the course of action. So we wait for the offline disks to change their state. Once the offline disks change their state to either one of these states we can decisively move forward. - nil (formatted disk) - errUnformattedDisk - Or any other error such as errCorruptedDisk. Fixes #4903
This commit is contained in:
committed by
Dee Koder
parent
f66239e82f
commit
b9fc4150f6
@@ -26,8 +26,8 @@ func (action InitActions) String() string {
|
||||
return "FormatDisks"
|
||||
case WaitForFormatting:
|
||||
return "WaitForFormatting"
|
||||
case WaitForHeal:
|
||||
return "WaitForHeal"
|
||||
case SuggestToHeal:
|
||||
return "SuggestToHeal"
|
||||
case WaitForAll:
|
||||
return "WaitForAll"
|
||||
case WaitForQuorum:
|
||||
@@ -76,6 +76,7 @@ func TestPrepForInitXL(t *testing.T) {
|
||||
errUnformattedDisk, errUnformattedDisk, errUnformattedDisk, errUnformattedDisk,
|
||||
errUnformattedDisk, errCorruptedFormat, errCorruptedFormat, errDiskNotFound,
|
||||
}
|
||||
|
||||
// Quorum number of disks not online yet.
|
||||
noQuourm := []error{
|
||||
errDiskNotFound, errDiskNotFound, errDiskNotFound, errDiskNotFound,
|
||||
@@ -101,6 +102,20 @@ func TestPrepForInitXL(t *testing.T) {
|
||||
nil, nil, nil, nil,
|
||||
errServerTimeMismatch, nil, nil, nil,
|
||||
}
|
||||
// Suggest to heal under formatted disks in quorum.
|
||||
formattedDisksInQuorum := []error{
|
||||
nil, nil, nil, nil,
|
||||
errUnformattedDisk, errUnformattedDisk, errDiskNotFound, errDiskNotFound,
|
||||
}
|
||||
// Wait for all under undecisive state.
|
||||
undecisiveErrs1 := []error{
|
||||
errDiskNotFound, nil, nil, nil,
|
||||
errUnformattedDisk, errUnformattedDisk, errDiskNotFound, errDiskNotFound,
|
||||
}
|
||||
undecisiveErrs2 := []error{
|
||||
errDiskNotFound, errDiskNotFound, errDiskNotFound, errDiskNotFound,
|
||||
errUnformattedDisk, errUnformattedDisk, errUnformattedDisk, errUnformattedDisk,
|
||||
}
|
||||
|
||||
testCases := []struct {
|
||||
// Params for prepForInit().
|
||||
@@ -116,7 +131,7 @@ func TestPrepForInitXL(t *testing.T) {
|
||||
{true, quorumUnformatted, 8, WaitForAll},
|
||||
{true, quorumUnformattedSomeCorrupted, 8, Abort},
|
||||
{true, noQuourm, 8, WaitForQuorum},
|
||||
{true, minorityCorrupted, 8, WaitForHeal},
|
||||
{true, minorityCorrupted, 8, SuggestToHeal},
|
||||
{true, majorityCorrupted, 8, Abort},
|
||||
// Remote disks.
|
||||
{false, allFormatted, 8, InitObjectLayer},
|
||||
@@ -125,8 +140,11 @@ func TestPrepForInitXL(t *testing.T) {
|
||||
{false, quorumUnformatted, 8, WaitForAll},
|
||||
{false, quorumUnformattedSomeCorrupted, 8, Abort},
|
||||
{false, noQuourm, 8, WaitForQuorum},
|
||||
{false, minorityCorrupted, 8, WaitForHeal},
|
||||
{false, minorityCorrupted, 8, SuggestToHeal},
|
||||
{false, formattedDisksInQuorum, 8, SuggestToHeal},
|
||||
{false, majorityCorrupted, 8, Abort},
|
||||
{false, undecisiveErrs1, 8, WaitForAll},
|
||||
{false, undecisiveErrs2, 8, WaitForAll},
|
||||
// Config mistakes.
|
||||
{true, accessKeyIDErr, 8, WaitForConfig},
|
||||
{true, authenticationErr, 8, WaitForConfig},
|
||||
@@ -136,7 +154,7 @@ func TestPrepForInitXL(t *testing.T) {
|
||||
for i, test := range testCases {
|
||||
actual := prepForInitXL(test.firstDisk, test.errs, test.diskCount)
|
||||
if actual != test.action {
|
||||
t.Errorf("Test %d expected %s but receieved %s\n", i+1, test.action, actual)
|
||||
t.Errorf("Test %d expected %s but received %s\n", i+1, test.action, actual)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user