Return 503 instead of 404 if more than half of disks are not found (#6207)

Fixes #6163
This commit is contained in:
kannappanr
2018-07-31 00:23:29 -07:00
committed by Harshavardhana
parent df88421087
commit 264cc4020f
10 changed files with 39 additions and 25 deletions

View File

@@ -119,8 +119,14 @@ func listOnlineDisks(disks []StorageAPI, partsMetadata []xlMetaV1, errs []error)
return onlineDisks, modTime
}
// Returns one of the latest updated xlMeta files and count of total valid xlMeta(s) updated latest
func getLatestXLMeta(partsMetadata []xlMetaV1, errs []error) (xlMetaV1, int) {
// Returns the latest updated xlMeta files and error in case of failure.
func getLatestXLMeta(ctx context.Context, partsMetadata []xlMetaV1, errs []error) (xlMetaV1, error) {
// There should be atleast half correct entries, if not return failure
if reducedErr := reduceReadQuorumErrs(ctx, errs, objectOpIgnoredErrs, globalXLSetDriveCount/2); reducedErr != nil {
return xlMetaV1{}, reducedErr
}
// List all the file commit ids from parts metadata.
modTimes := listObjectModtimes(partsMetadata, errs)
@@ -138,8 +144,11 @@ func getLatestXLMeta(partsMetadata []xlMetaV1, errs []error) (xlMetaV1, int) {
count++
}
}
// Return one of the latest xlMetaData, and the count of lastest updated xlMeta files
return latestXLMeta, count
if count < len(partsMetadata)/2 {
return xlMetaV1{}, errXLReadQuorum
}
return latestXLMeta, nil
}
// disksWithAllParts - This function needs to be called with