mirror of
https://github.com/minio/minio.git
synced 2025-04-20 18:44:21 -04:00
allow changing endpoints in distributed setups (#16071)
This commit is contained in:
parent
3597af789e
commit
853c4de75a
@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2015-2021 MinIO, Inc.
|
// Copyright (c) 2015-2022 MinIO, Inc.
|
||||||
//
|
//
|
||||||
// This file is part of MinIO Object Storage stack
|
// This file is part of MinIO Object Storage stack
|
||||||
//
|
//
|
||||||
@ -64,6 +64,7 @@ func (s1 ServerSystemConfig) Diff(s2 ServerSystemConfig) error {
|
|||||||
return fmt.Errorf("Expected platform '%s', found to be running '%s'",
|
return fmt.Errorf("Expected platform '%s', found to be running '%s'",
|
||||||
s1.MinioPlatform, s2.MinioPlatform)
|
s1.MinioPlatform, s2.MinioPlatform)
|
||||||
}
|
}
|
||||||
|
|
||||||
if s1.MinioEndpoints.NEndpoints() != s2.MinioEndpoints.NEndpoints() {
|
if s1.MinioEndpoints.NEndpoints() != s2.MinioEndpoints.NEndpoints() {
|
||||||
return fmt.Errorf("Expected number of endpoints %d, seen %d", s1.MinioEndpoints.NEndpoints(),
|
return fmt.Errorf("Expected number of endpoints %d, seen %d", s1.MinioEndpoints.NEndpoints(),
|
||||||
s2.MinioEndpoints.NEndpoints())
|
s2.MinioEndpoints.NEndpoints())
|
||||||
@ -200,15 +201,18 @@ func verifyServerSystemConfig(ctx context.Context, endpointServerPools EndpointS
|
|||||||
srcCfg := getServerSystemCfg()
|
srcCfg := getServerSystemCfg()
|
||||||
clnts := newBootstrapRESTClients(endpointServerPools)
|
clnts := newBootstrapRESTClients(endpointServerPools)
|
||||||
var onlineServers int
|
var onlineServers int
|
||||||
var offlineEndpoints []string
|
var offlineEndpoints []error
|
||||||
|
var incorrectConfigs []error
|
||||||
var retries int
|
var retries int
|
||||||
for onlineServers < len(clnts)/2 {
|
for onlineServers < len(clnts)/2 {
|
||||||
for _, clnt := range clnts {
|
for _, clnt := range clnts {
|
||||||
if err := clnt.Verify(ctx, srcCfg); err != nil {
|
if err := clnt.Verify(ctx, srcCfg); err != nil {
|
||||||
if !isNetworkError(err) {
|
if !isNetworkError(err) {
|
||||||
logger.LogIf(ctx, fmt.Errorf("%s has incorrect configuration: %w", clnt.String(), err))
|
logger.LogOnceIf(ctx, fmt.Errorf("%s has incorrect configuration: %w", clnt.String(), err), clnt.String())
|
||||||
|
incorrectConfigs = append(incorrectConfigs, fmt.Errorf("%s has incorrect configuration: %w", clnt.String(), err))
|
||||||
|
} else {
|
||||||
|
offlineEndpoints = append(offlineEndpoints, fmt.Errorf("%s is unreachable: %w", clnt.String(), err))
|
||||||
}
|
}
|
||||||
offlineEndpoints = append(offlineEndpoints, clnt.String())
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
onlineServers++
|
onlineServers++
|
||||||
@ -221,15 +225,19 @@ func verifyServerSystemConfig(ctx context.Context, endpointServerPools EndpointS
|
|||||||
// 100% CPU when half the endpoints are offline.
|
// 100% CPU when half the endpoints are offline.
|
||||||
time.Sleep(100 * time.Millisecond)
|
time.Sleep(100 * time.Millisecond)
|
||||||
retries++
|
retries++
|
||||||
// after 5 retries start logging that servers are not reachable yet
|
// after 20 retries start logging that servers are not reachable yet
|
||||||
if retries >= 5 {
|
if retries >= 20 {
|
||||||
logger.Info(fmt.Sprintf("Waiting for atleast %d remote servers to be online for bootstrap check", len(clnts)/2))
|
logger.Info(fmt.Sprintf("Waiting for atleast %d remote servers with valid configuration to be online", len(clnts)/2))
|
||||||
if len(offlineEndpoints) > 0 {
|
if len(offlineEndpoints) > 0 {
|
||||||
logger.Info(fmt.Sprintf("Following servers are currently offline or unreachable %s", offlineEndpoints))
|
logger.Info(fmt.Sprintf("Following servers are currently offline or unreachable %s", offlineEndpoints))
|
||||||
}
|
}
|
||||||
|
if len(incorrectConfigs) > 0 {
|
||||||
|
logger.Info(fmt.Sprintf("Following servers mismatch in their configuration %s", incorrectConfigs))
|
||||||
|
}
|
||||||
retries = 0 // reset to log again after 5 retries.
|
retries = 0 // reset to log again after 5 retries.
|
||||||
}
|
}
|
||||||
offlineEndpoints = nil
|
offlineEndpoints = nil
|
||||||
|
incorrectConfigs = nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -317,7 +317,7 @@ func (p *poolMeta) validate(pools []*erasureSets) (bool, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
replaceScheme := func(k string) string {
|
replaceScheme := func(k string) string {
|
||||||
// This is needed as fallback when users are changeing
|
// This is needed as fallback when users are updating
|
||||||
// from http->https or https->http, we need to verify
|
// from http->https or https->http, we need to verify
|
||||||
// both because MinIO remembers the command-line in
|
// both because MinIO remembers the command-line in
|
||||||
// "exact" order - as long as this order is not disturbed
|
// "exact" order - as long as this order is not disturbed
|
||||||
@ -359,11 +359,7 @@ func (p *poolMeta) validate(pools []*erasureSets) (bool, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !ok {
|
if !ok {
|
||||||
if globalIsErasureSD {
|
|
||||||
update = true
|
update = true
|
||||||
} else {
|
|
||||||
return false, fmt.Errorf("pool(%s) = %s is not specified, please specify on server command line", humanize.Ordinal(pi.position+1), k)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -378,11 +374,7 @@ func (p *poolMeta) validate(pools []*erasureSets) (bool, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !ok {
|
if !ok {
|
||||||
if globalIsErasureSD {
|
|
||||||
update = true
|
update = true
|
||||||
} else {
|
|
||||||
return false, fmt.Errorf("pool(%s) = %s is not specified, please specify on server command line", humanize.Ordinal(pi.position+1), k)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if ok && pos != pi.position {
|
if ok && pos != pi.position {
|
||||||
return false, fmt.Errorf("pool order change detected for %s, expected position is (%s) but found (%s)", k, humanize.Ordinal(pi.position+1), humanize.Ordinal(pos+1))
|
return false, fmt.Errorf("pool order change detected for %s, expected position is (%s) but found (%s)", k, humanize.Ordinal(pi.position+1), humanize.Ordinal(pos+1))
|
||||||
@ -400,6 +392,7 @@ func (p *poolMeta) validate(pools []*erasureSets) (bool, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return update, nil
|
return update, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,16 +112,16 @@ func TestPoolMetaValidate(t *testing.T) {
|
|||||||
{
|
{
|
||||||
meta: meta,
|
meta: meta,
|
||||||
pools: newPools,
|
pools: newPools,
|
||||||
name: "Invalid-Commandline",
|
name: "Correct-Update",
|
||||||
expectedErr: true,
|
expectedErr: false,
|
||||||
expectedUpdate: false,
|
expectedUpdate: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
meta: meta,
|
meta: meta,
|
||||||
pools: reducedPools,
|
pools: reducedPools,
|
||||||
name: "Invalid-Reduced",
|
name: "Correct-Update",
|
||||||
expectedErr: true,
|
expectedErr: false,
|
||||||
expectedUpdate: false,
|
expectedUpdate: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
meta: meta,
|
meta: meta,
|
||||||
|
@ -568,7 +568,7 @@ func serverMain(ctx *cli.Context) {
|
|||||||
|
|
||||||
setHTTPServer(httpServer)
|
setHTTPServer(httpServer)
|
||||||
|
|
||||||
if globalIsDistErasure && globalEndpoints.FirstLocal() {
|
if globalIsDistErasure {
|
||||||
// Additionally in distributed setup, validate the setup and configuration.
|
// Additionally in distributed setup, validate the setup and configuration.
|
||||||
if err := verifyServerSystemConfig(GlobalContext, globalEndpoints); err != nil {
|
if err := verifyServerSystemConfig(GlobalContext, globalEndpoints); err != nil {
|
||||||
logger.Fatal(err, "Unable to start the server")
|
logger.Fatal(err, "Unable to start the server")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user