fix: throw error if symmetry cannot be obtained (#9780)

For example `{1...17}/{1...52}` symmetrical
distribution of drives cannot be obtained

- Because 17 is a prime number
- Is not divisible by any pre-defined setCounts i.e
  from 1 to 16
master
Harshavardhana 5 years ago committed by GitHub
parent e906b511e9
commit c7599d323b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      cmd/endpoint-ellipses.go
  2. 12
      cmd/endpoint-ellipses_test.go

@ -181,6 +181,11 @@ func getSetIndexes(args []string, totalSizes []uint64, customSetDriveCount uint6
// Returns possible set counts with symmetry. // Returns possible set counts with symmetry.
setCounts = possibleSetCountsWithSymmetry(setCounts, argPatterns) setCounts = possibleSetCountsWithSymmetry(setCounts, argPatterns)
if len(setCounts) == 0 {
msg := fmt.Sprintf("No symmetric distribution detected with input endpoints provided %s, disks %d cannot be spread symmetrically by any supported erasure set sizes %d", args, commonSize, setSizes)
return nil, config.ErrInvalidNumberOfErasureEndpoints(nil).Msg(msg)
}
// Final set size with all the symmetry accounted for. // Final set size with all the symmetry accounted for.
setSize = commonSetDriveCount(commonSize, setCounts) setSize = commonSetDriveCount(commonSize, setCounts)
} }

@ -211,6 +211,12 @@ func TestGetSetIndexes(t *testing.T) {
nil, nil,
false, false,
}, },
{
[]string{"data{1...17}/export{1...52}"},
[]uint64{14144},
nil,
false,
},
// Valid inputs. // Valid inputs.
{ {
[]string{"data{1...27}"}, []string{"data{1...27}"},
@ -272,6 +278,12 @@ func TestGetSetIndexes(t *testing.T) {
[][]uint64{{10}, {10}, {10}}, [][]uint64{{10}, {10}, {10}},
true, true,
}, },
{
[]string{"data{1...16}/export{1...52}"},
[]uint64{832},
[][]uint64{{16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16}},
true,
},
} }
for _, testCase := range testCases { for _, testCase := range testCases {

Loading…
Cancel
Save