diff --git a/cmd/bootstrap-peer-server.go b/cmd/bootstrap-peer-server.go index 88653bb17..6e5f6f444 100644 --- a/cmd/bootstrap-peer-server.go +++ b/cmd/bootstrap-peer-server.go @@ -20,12 +20,14 @@ package cmd import ( "context" "encoding/json" + "errors" "fmt" "io" "net/http" "net/url" "os" "reflect" + "strings" "time" "github.com/minio/minio-go/v7/pkg/set" @@ -82,23 +84,40 @@ func (s1 ServerSystemConfig) Diff(s2 ServerSystemConfig) error { ep.Platform, s2.MinioEndpoints[i].Platform) } } - if !reflect.DeepEqual(s1.MinioEnv, s2.MinioEnv) { - var missing []string - var mismatching []string - for k, v := range s1.MinioEnv { - ev, ok := s2.MinioEnv[k] - if !ok { - missing = append(missing, k) - } else if v != ev { - mismatching = append(mismatching, k) - } - } - if len(mismatching) > 0 { - return fmt.Errorf(`Expected same MINIO_ environment variables and values across all servers: Missing environment values: %s / Mismatch environment values: %s`, missing, mismatching) - } - return fmt.Errorf(`Expected same MINIO_ environment variables and values across all servers: Missing environment values: %s`, missing) + if reflect.DeepEqual(s1.MinioEnv, s2.MinioEnv) { + return nil } - return nil + + // Report differences in environment variables. + var missing []string + var mismatching []string + for k, v := range s1.MinioEnv { + ev, ok := s2.MinioEnv[k] + if !ok { + missing = append(missing, k) + } else if v != ev { + mismatching = append(mismatching, k) + } + } + var extra []string + for k := range s2.MinioEnv { + _, ok := s1.MinioEnv[k] + if !ok { + extra = append(extra, k) + } + } + msg := "Expected same MINIO_ environment variables and values across all servers: " + if len(missing) > 0 { + msg += fmt.Sprintf(`Missing environment values: %v. `, missing) + } + if len(mismatching) > 0 { + msg += fmt.Sprintf(`Mismatching environment values: %v. `, mismatching) + } + if len(extra) > 0 { + msg += fmt.Sprintf(`Extra environment values: %v. `, extra) + } + + return errors.New(strings.TrimSpace(msg)) } var skipEnvs = map[string]struct{}{