mirror of
https://github.com/pgsty/minio.git
synced 2026-08-06 07:41:16 +03:00
utils: reduceErrs returns and validates quorum errors. (#3300)
This is needed as explained by @krisis
Lets say we have following errors.
```
[]error{nil, errFileNotFound, errDiskAccessDenied, errDiskAccesDenied}
```
Since the last two errors are filtered, the maximum is nil,
depending on map order.
Let's say we get nil from reduceErr. Clearly at this point
we don't have quorum nodes agreeing about the data and since
GetObject only requires N/2 (Read quorum) and isDiskQuorum
would have returned true. This is problematic and can lead to
undersiable consequences.
Fixes #3298
This commit is contained in:
+10
-4
@@ -63,29 +63,35 @@ func TestReduceErrs(t *testing.T) {
|
||||
errDiskNotFound,
|
||||
errDiskNotFound,
|
||||
errDiskFull,
|
||||
}, []error{}, errDiskNotFound},
|
||||
}, []error{}, errXLReadQuorum},
|
||||
// Validate if have no consensus.
|
||||
{[]error{
|
||||
errDiskFull,
|
||||
errDiskNotFound,
|
||||
nil, nil,
|
||||
}, []error{}, nil},
|
||||
}, []error{}, errXLReadQuorum},
|
||||
// Validate if have consensus and errors ignored.
|
||||
{[]error{
|
||||
errVolumeNotFound,
|
||||
errVolumeNotFound,
|
||||
errVolumeNotFound,
|
||||
errVolumeNotFound,
|
||||
errVolumeNotFound,
|
||||
errDiskNotFound,
|
||||
errDiskNotFound,
|
||||
}, []error{errDiskNotFound}, errVolumeNotFound},
|
||||
{[]error{}, []error{}, nil},
|
||||
{[]error{}, []error{}, errXLReadQuorum},
|
||||
}
|
||||
// Validates list of all the testcases for returning valid errors.
|
||||
for i, testCase := range testCases {
|
||||
gotErr := reduceErrs(testCase.errs, testCase.ignoredErrs)
|
||||
gotErr := reduceReadQuorumErrs(testCase.errs, testCase.ignoredErrs, 5)
|
||||
if errorCause(gotErr) != testCase.err {
|
||||
t.Errorf("Test %d : expected %s, got %s", i+1, testCase.err, gotErr)
|
||||
}
|
||||
gotNewErr := reduceWriteQuorumErrs(testCase.errs, testCase.ignoredErrs, 6)
|
||||
if errorCause(gotNewErr) != errXLWriteQuorum {
|
||||
t.Errorf("Test %d : expected %s, got %s", i+1, errXLWriteQuorum, gotErr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user