From 88e0aa1cb27a2935457995f8af61975c47222bbd Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Mon, 30 Aug 2021 08:27:39 -0700 Subject: [PATCH] verify all nodes have same ENVs in bootstrap (#13096) --- cmd/bootstrap-peer-server.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/cmd/bootstrap-peer-server.go b/cmd/bootstrap-peer-server.go index 5d0e1a538..47fcc63d7 100644 --- a/cmd/bootstrap-peer-server.go +++ b/cmd/bootstrap-peer-server.go @@ -24,6 +24,7 @@ import ( "io" "net/http" "net/url" + "reflect" "runtime" "time" @@ -32,6 +33,7 @@ import ( xhttp "github.com/minio/minio/internal/http" "github.com/minio/minio/internal/logger" "github.com/minio/minio/internal/rest" + "github.com/minio/pkg/env" ) const ( @@ -52,8 +54,8 @@ type bootstrapRESTServer struct{} // ServerSystemConfig - captures information about server configuration. type ServerSystemConfig struct { MinioPlatform string - MinioRuntime string MinioEndpoints EndpointServerPools + MinioEnv map[string]string } // Diff - returns error on first difference found in two configs. @@ -82,15 +84,23 @@ func (s1 ServerSystemConfig) Diff(s2 ServerSystemConfig) error { s2.MinioEndpoints[i].Endpoints[j]) } } - + } + if !reflect.DeepEqual(s1.MinioEnv, s2.MinioEnv) { + return fmt.Errorf("Expected same MINIO_ environment variables and values") } return nil } func getServerSystemCfg() ServerSystemConfig { + envs := env.List("MINIO_") + envValues := make(map[string]string, len(envs)) + for _, envK := range envs { + envValues[envK] = env.Get(envK, "") + } return ServerSystemConfig{ MinioPlatform: fmt.Sprintf("OS: %s | Arch: %s", runtime.GOOS, runtime.GOARCH), MinioEndpoints: globalEndpoints, + MinioEnv: envValues, } }