allow bootstrap platform checks to be pool specific (#16455)

This commit is contained in:
Harshavardhana 2023-01-23 16:24:50 +05:30 committed by GitHub
parent 54c9ecff5b
commit eb561e1c05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 14 deletions

View File

@ -25,7 +25,6 @@ import (
"net/http" "net/http"
"net/url" "net/url"
"reflect" "reflect"
"runtime"
"time" "time"
"github.com/gorilla/mux" "github.com/gorilla/mux"
@ -53,24 +52,22 @@ type bootstrapRESTServer struct{}
// ServerSystemConfig - captures information about server configuration. // ServerSystemConfig - captures information about server configuration.
type ServerSystemConfig struct { type ServerSystemConfig struct {
MinioPlatform string
MinioEndpoints EndpointServerPools MinioEndpoints EndpointServerPools
MinioEnv map[string]string MinioEnv map[string]string
} }
// Diff - returns error on first difference found in two configs. // Diff - returns error on first difference found in two configs.
func (s1 ServerSystemConfig) Diff(s2 ServerSystemConfig) error { func (s1 ServerSystemConfig) Diff(s2 ServerSystemConfig) error {
if s1.MinioPlatform != s2.MinioPlatform {
return fmt.Errorf("Expected platform '%s', found to be running '%s'",
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())
} }
for i, ep := range s1.MinioEndpoints { for i, ep := range s1.MinioEndpoints {
if ep.CmdLine != s2.MinioEndpoints[i].CmdLine {
return fmt.Errorf("Expected command line argument %s, seen %s", ep.CmdLine,
s2.MinioEndpoints[i].CmdLine)
}
if ep.SetCount != s2.MinioEndpoints[i].SetCount { if ep.SetCount != s2.MinioEndpoints[i].SetCount {
return fmt.Errorf("Expected set count %d, seen %d", ep.SetCount, return fmt.Errorf("Expected set count %d, seen %d", ep.SetCount,
s2.MinioEndpoints[i].SetCount) s2.MinioEndpoints[i].SetCount)
@ -79,11 +76,9 @@ func (s1 ServerSystemConfig) Diff(s2 ServerSystemConfig) error {
return fmt.Errorf("Expected drives pet set %d, seen %d", ep.DrivesPerSet, return fmt.Errorf("Expected drives pet set %d, seen %d", ep.DrivesPerSet,
s2.MinioEndpoints[i].DrivesPerSet) s2.MinioEndpoints[i].DrivesPerSet)
} }
for j, endpoint := range ep.Endpoints { if ep.Platform != s2.MinioEndpoints[i].Platform {
if endpoint.String() != s2.MinioEndpoints[i].Endpoints[j].String() { return fmt.Errorf("Expected platform '%s', found to be on '%s'",
return fmt.Errorf("Expected endpoint %s, seen %s", endpoint, ep.Platform, s2.MinioEndpoints[i].Platform)
s2.MinioEndpoints[i].Endpoints[j])
}
} }
} }
if !reflect.DeepEqual(s1.MinioEnv, s2.MinioEnv) { if !reflect.DeepEqual(s1.MinioEnv, s2.MinioEnv) {
@ -126,7 +121,6 @@ func getServerSystemCfg() ServerSystemConfig {
envValues[envK] = env.Get(envK, "") envValues[envK] = env.Get(envK, "")
} }
return ServerSystemConfig{ return ServerSystemConfig{
MinioPlatform: fmt.Sprintf("OS: %s | Arch: %s", runtime.GOOS, runtime.GOARCH),
MinioEndpoints: globalEndpoints, MinioEndpoints: globalEndpoints,
MinioEnv: envValues, MinioEnv: envValues,
} }
@ -232,7 +226,7 @@ func verifyServerSystemConfig(ctx context.Context, endpointServerPools EndpointS
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 { if len(incorrectConfigs) > 0 {
logger.Info(fmt.Sprintf("Following servers mismatch in their configuration %s", incorrectConfigs)) logger.Info(fmt.Sprintf("Following servers have mismatching configuration %s", incorrectConfigs))
} }
retries = 0 // reset to log again after 5 retries. retries = 0 // reset to log again after 5 retries.
} }

View File

@ -19,6 +19,7 @@ package cmd
import ( import (
"fmt" "fmt"
"runtime"
"sort" "sort"
"strconv" "strconv"
"strings" "strings"
@ -364,6 +365,7 @@ func createServerEndpoints(serverAddr string, args ...string) (
DrivesPerSet: len(setArgs[0]), DrivesPerSet: len(setArgs[0]),
Endpoints: endpointList, Endpoints: endpointList,
CmdLine: strings.Join(args, " "), CmdLine: strings.Join(args, " "),
Platform: fmt.Sprintf("OS: %s | Arch: %s", runtime.GOOS, runtime.GOARCH),
}) })
setupType = newSetupType setupType = newSetupType
return endpointServerPools, setupType, nil return endpointServerPools, setupType, nil
@ -389,6 +391,7 @@ func createServerEndpoints(serverAddr string, args ...string) (
DrivesPerSet: len(setArgs[0]), DrivesPerSet: len(setArgs[0]),
Endpoints: endpointList, Endpoints: endpointList,
CmdLine: arg, CmdLine: arg,
Platform: fmt.Sprintf("OS: %s | Arch: %s", runtime.GOOS, runtime.GOARCH),
}); err != nil { }); err != nil {
return nil, -1, err return nil, -1, err
} }

View File

@ -203,6 +203,7 @@ type PoolEndpoints struct {
DrivesPerSet int DrivesPerSet int
Endpoints Endpoints Endpoints Endpoints
CmdLine string CmdLine string
Platform string
} }
// EndpointServerPools - list of list of endpoints // EndpointServerPools - list of list of endpoints