From 622087580373fe61ebf5753c410885a8db2d23bd Mon Sep 17 00:00:00 2001 From: Klaus Post Date: Tue, 11 Oct 2022 20:31:26 +0200 Subject: [PATCH] Add missing server info fields (#15826) --- cmd/admin-handlers.go | 7 ++++- cmd/admin-server-info.go | 58 ++++++++++++++++++++++++++++++++++++++++ go.mod | 2 +- go.sum | 4 +-- 4 files changed, 67 insertions(+), 4 deletions(-) diff --git a/cmd/admin-handlers.go b/cmd/admin-handlers.go index ec3f0dae8..d91d8c585 100644 --- a/cmd/admin-handlers.go +++ b/cmd/admin-handlers.go @@ -2264,7 +2264,7 @@ func (a adminAPIHandlers) HealthInfoHandler(w http.ResponseWriter, r *http.Reque if query.Get("minioinfo") == "true" { infoMessage := getServerInfo(ctx, r) - servers := []madmin.ServerInfo{} + servers := make([]madmin.ServerInfo, 0, len(infoMessage.Servers)) for _, server := range infoMessage.Servers { anonEndpoint := anonAddr(server.Endpoint) servers = append(servers, madmin.ServerInfo{ @@ -2283,6 +2283,11 @@ func (a adminAPIHandlers) HealthInfoHandler(w http.ResponseWriter, r *http.Reque Frees: server.MemStats.Frees, HeapAlloc: server.MemStats.HeapAlloc, }, + GoMaxProcs: server.GoMaxProcs, + NumCPU: server.NumCPU, + RuntimeVersion: server.RuntimeVersion, + GCStats: server.GCStats, + MinioEnvVars: server.MinioEnvVars, }) } diff --git a/cmd/admin-server-info.go b/cmd/admin-server-info.go index 0105ed26e..7b41b5333 100644 --- a/cmd/admin-server-info.go +++ b/cmd/admin-server-info.go @@ -20,10 +20,14 @@ package cmd import ( "context" "net/http" + "os" "runtime" + "runtime/debug" + "strings" "time" "github.com/minio/madmin-go" + "github.com/minio/minio/internal/config" "github.com/minio/minio/internal/logger" ) @@ -67,6 +71,22 @@ func getLocalServerProperty(endpointServerPools EndpointServerPools, r *http.Req var memstats runtime.MemStats runtime.ReadMemStats(&memstats) + gcStats := debug.GCStats{ + // If stats.PauseQuantiles is non-empty, ReadGCStats fills + // it with quantiles summarizing the distribution of pause time. + // For example, if len(stats.PauseQuantiles) is 5, it will be + // filled with the minimum, 25%, 50%, 75%, and maximum pause times. + PauseQuantiles: make([]time.Duration, 5), + } + debug.ReadGCStats(&gcStats) + // Truncate GC stats to max 5 entries. + if len(gcStats.PauseEnd) > 5 { + gcStats.PauseEnd = gcStats.PauseEnd[len(gcStats.PauseEnd)-5:] + } + if len(gcStats.Pause) > 5 { + gcStats.Pause = gcStats.Pause[len(gcStats.Pause)-5:] + } + props := madmin.ServerProperties{ State: string(madmin.ItemInitializing), Endpoint: addr, @@ -81,6 +101,44 @@ func getLocalServerProperty(endpointServerPools EndpointServerPools, r *http.Req Frees: memstats.Frees, HeapAlloc: memstats.HeapAlloc, }, + GoMaxProcs: runtime.GOMAXPROCS(0), + NumCPU: runtime.NumCPU(), + RuntimeVersion: runtime.Version(), + GCStats: &madmin.GCStats{ + LastGC: gcStats.LastGC, + NumGC: gcStats.NumGC, + PauseTotal: gcStats.PauseTotal, + Pause: gcStats.Pause, + PauseEnd: gcStats.PauseEnd, + }, + MinioEnvVars: make(map[string]string, 10), + } + + sensitive := map[string]struct{}{ + config.EnvAccessKey: {}, + config.EnvSecretKey: {}, + config.EnvRootUser: {}, + config.EnvRootPassword: {}, + config.EnvMinIOSubnetAPIKey: {}, + config.EnvKMSSecretKey: {}, + } + for _, v := range os.Environ() { + if !strings.HasPrefix(v, "MINIO") && !strings.HasPrefix(v, "_MINIO") { + continue + } + split := strings.SplitN(v, "=", 2) + key := split[0] + value := "" + if len(split) > 1 { + value = split[1] + } + + // Do not send sensitive creds. + if _, ok := sensitive[key]; ok || strings.Contains(strings.ToLower(key), "password") || strings.HasSuffix(strings.ToLower(key), "key") { + props.MinioEnvVars[key] = "*** EXISTS, REDACTED ***" + continue + } + props.MinioEnvVars[key] = value } objLayer := newObjectLayerFn() diff --git a/go.mod b/go.mod index 772ec9f7c..e422dbd7f 100644 --- a/go.mod +++ b/go.mod @@ -48,7 +48,7 @@ require ( github.com/minio/dperf v0.4.2 github.com/minio/highwayhash v1.0.2 github.com/minio/kes v0.21.0 - github.com/minio/madmin-go v1.5.3 + github.com/minio/madmin-go v1.6.2 github.com/minio/minio-go/v7 v7.0.40-0.20220928095841-8848d8affe8a github.com/minio/pkg v1.5.0 github.com/minio/selfupdate v0.5.0 diff --git a/go.sum b/go.sum index 36c79889c..d49dff360 100644 --- a/go.sum +++ b/go.sum @@ -651,8 +651,8 @@ github.com/minio/highwayhash v1.0.2/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLT github.com/minio/kes v0.21.0 h1:Xe0vNRyBgC35TZkbOnU4hAgJRBEaFcT6KiI9/29BdUo= github.com/minio/kes v0.21.0/go.mod h1:3FW1BQkMGQW78yhy+69tUq5bdcf5rnXJizyeKB9a/tc= github.com/minio/madmin-go v1.3.5/go.mod h1:vGKGboQgGIWx4DuDUaXixjlIEZOCIp6ivJkQoiVaACc= -github.com/minio/madmin-go v1.5.3 h1:G/xtuOzKuQf2wJhyH2I/wyO6aNzkHQm1sUmpdURbScY= -github.com/minio/madmin-go v1.5.3/go.mod h1:ez87VmMtsxP7DRxjKJKD4RDNW+nhO2QF9KSzwxBDQ98= +github.com/minio/madmin-go v1.6.2 h1:Nn9dy287ZqiyJeuDg1V3mlWTVmotwQBlUI9XomhC+Zg= +github.com/minio/madmin-go v1.6.2/go.mod h1:FVl1TS8T79779KZEboPHL5byffHJ6DyrAAavqgsG6UQ= github.com/minio/mc v0.0.0-20221001175248-68ca2bf457e4 h1:DStvFAaRrNCvAa6je41F8WBgziXeF1sZymSQJCWxbKY= github.com/minio/mc v0.0.0-20221001175248-68ca2bf457e4/go.mod h1:cqIVmUIAVDVCwR2/XztvlBdZpbI/hPx0ilEOvtG47Tw= github.com/minio/md5-simd v1.1.0/go.mod h1:XpBqgZULrMYD3R+M28PcmP0CkI7PEMzB3U77ZrKZ0Gw=