fix: all hosts local and port same should be local erasure setup (#10951)

this is needed to avoid initializing notification peers
that can lead to races in many sub-systems

fixes #10950
master
Harshavardhana 4 years ago committed by GitHub
parent df93102235
commit 734d07a532
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      cmd/endpoint-ellipses.go
  2. 4
      cmd/endpoint.go
  3. 2
      cmd/endpoint_test.go

@ -361,24 +361,19 @@ func createServerEndpoints(serverAddr string, args ...string) (
return endpointServerSets, setupType, nil return endpointServerSets, setupType, nil
} }
var prevSetupType SetupType
var foundPrevLocal bool var foundPrevLocal bool
for _, arg := range args { for _, arg := range args {
setArgs, err := GetAllSets(uint64(setDriveCount), arg) setArgs, err := GetAllSets(uint64(setDriveCount), arg)
if err != nil { if err != nil {
return nil, -1, err return nil, -1, err
} }
var endpointList Endpoints endpointList, gotSetupType, err := CreateEndpoints(serverAddr, foundPrevLocal, setArgs...)
endpointList, setupType, err = CreateEndpoints(serverAddr, foundPrevLocal, setArgs...)
if err != nil { if err != nil {
return nil, -1, err return nil, -1, err
} }
if setDriveCount != 0 && setDriveCount != len(setArgs[0]) { if setDriveCount != 0 && setDriveCount != len(setArgs[0]) {
return nil, -1, fmt.Errorf("All serverSets should have same drive per set ratio - expected %d, got %d", setDriveCount, len(setArgs[0])) return nil, -1, fmt.Errorf("All serverSets should have same drive per set ratio - expected %d, got %d", setDriveCount, len(setArgs[0]))
} }
if prevSetupType != UnknownSetupType && prevSetupType != setupType {
return nil, -1, fmt.Errorf("All serverSets should be of the same setup-type to maintain the original SLA expectations - expected %s, got %s", prevSetupType, setupType)
}
if err = endpointServerSets.Add(ZoneEndpoints{ if err = endpointServerSets.Add(ZoneEndpoints{
SetCount: len(setArgs), SetCount: len(setArgs),
DrivesPerSet: len(setArgs[0]), DrivesPerSet: len(setArgs[0]),
@ -390,7 +385,12 @@ func createServerEndpoints(serverAddr string, args ...string) (
if setDriveCount == 0 { if setDriveCount == 0 {
setDriveCount = len(setArgs[0]) setDriveCount = len(setArgs[0])
} }
prevSetupType = setupType if setupType == UnknownSetupType {
setupType = gotSetupType
}
if setupType == ErasureSetupType && gotSetupType == DistErasureSetupType {
setupType = DistErasureSetupType
}
} }
return endpointServerSets, setupType, nil return endpointServerSets, setupType, nil

@ -689,14 +689,14 @@ func CreateEndpoints(serverAddr string, foundLocal bool, args ...[]string) (Endp
// All endpoints are pointing to local host // All endpoints are pointing to local host
if len(endpoints) == localEndpointCount { if len(endpoints) == localEndpointCount {
// If all endpoints have same port number, Just treat it as distErasure setup // If all endpoints have same port number, Just treat it as local erasure setup
// using URL style endpoints. // using URL style endpoints.
if len(localPortSet) == 1 { if len(localPortSet) == 1 {
if len(localServerHostSet) > 1 { if len(localServerHostSet) > 1 {
return endpoints, setupType, return endpoints, setupType,
config.ErrInvalidErasureEndpoints(nil).Msg("all local endpoints should not have different hostnames/ips") config.ErrInvalidErasureEndpoints(nil).Msg("all local endpoints should not have different hostnames/ips")
} }
return endpoints, DistErasureSetupType, nil return endpoints, ErasureSetupType, nil
} }
// Even though all endpoints are local, but those endpoints use different ports. // Even though all endpoints are local, but those endpoints use different ports.

@ -246,7 +246,7 @@ func TestCreateEndpoints(t *testing.T) {
Endpoint{URL: &url.URL{Scheme: "http", Host: "localhost", Path: "/d2"}, IsLocal: true}, Endpoint{URL: &url.URL{Scheme: "http", Host: "localhost", Path: "/d2"}, IsLocal: true},
Endpoint{URL: &url.URL{Scheme: "http", Host: "localhost", Path: "/d3"}, IsLocal: true}, Endpoint{URL: &url.URL{Scheme: "http", Host: "localhost", Path: "/d3"}, IsLocal: true},
Endpoint{URL: &url.URL{Scheme: "http", Host: "localhost", Path: "/d4"}, IsLocal: true}, Endpoint{URL: &url.URL{Scheme: "http", Host: "localhost", Path: "/d4"}, IsLocal: true},
}, DistErasureSetupType, nil}, }, ErasureSetupType, nil},
// DistErasure Setup with URLEndpointType having mixed naming to local host. // DistErasure Setup with URLEndpointType having mixed naming to local host.
{"127.0.0.1:10000", [][]string{{"http://localhost/d1", "http://localhost/d2", "http://127.0.0.1/d3", "http://127.0.0.1/d4"}}, "", Endpoints{}, -1, fmt.Errorf("all local endpoints should not have different hostnames/ips")}, {"127.0.0.1:10000", [][]string{{"http://localhost/d1", "http://localhost/d2", "http://127.0.0.1/d3", "http://127.0.0.1/d4"}}, "", Endpoints{}, -1, fmt.Errorf("all local endpoints should not have different hostnames/ips")},

Loading…
Cancel
Save