From 9371852c7de39e5dc2e3539605c3e86e674b142d Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Mon, 2 Aug 2021 21:50:20 -0700 Subject: [PATCH] fix: getAPIEndpoints() should return public_url (#12852) fixes #12850 --- cmd/admin-handlers.go | 13 +++++++------ cmd/net.go | 3 +++ cmd/notification.go | 8 ++++++-- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/cmd/admin-handlers.go b/cmd/admin-handlers.go index 9b97ef00d..bc2d7a0ee 100644 --- a/cmd/admin-handlers.go +++ b/cmd/admin-handlers.go @@ -2316,12 +2316,13 @@ func createHostAnonymizerForFSMode() map[string]string { apiEndpoints := getAPIEndpoints() for _, ep := range apiEndpoints { - if len(ep) > 0 { - if url, err := xnet.ParseHTTPURL(ep); err == nil { - // In FS mode the drive names don't include the host. - // So mapping just the host should be sufficient. - hostAnonymizer[url.Host] = "server1" - } + if len(ep) == 0 { + continue + } + if url, err := xnet.ParseHTTPURL(ep); err == nil { + // In FS mode the drive names don't include the host. + // So mapping just the host should be sufficient. + hostAnonymizer[url.Host] = "server1" } } return hostAnonymizer diff --git a/cmd/net.go b/cmd/net.go index 9caa0f04e..32e367232 100644 --- a/cmd/net.go +++ b/cmd/net.go @@ -177,6 +177,9 @@ func getConsoleEndpoints() (consoleEndpoints []string) { } func getAPIEndpoints() (apiEndpoints []string) { + if globalMinioEndpoint != "" { + return []string{globalMinioEndpoint} + } var ipList []string if globalMinioHost == "" { ipList = sortIPs(mustGetLocalIP4().ToSlice()) diff --git a/cmd/notification.go b/cmd/notification.go index 0956e3af9..72ef67d2e 100644 --- a/cmd/notification.go +++ b/cmd/notification.go @@ -1461,7 +1461,7 @@ func (sys *NotificationSys) GetClusterMetrics(ctx context.Context) chan Metric { // Speedtest run GET/PUT tests at input concurrency for requested object size, // optionally you can extend the tests longer with time.Duration. func (sys *NotificationSys) Speedtest(ctx context.Context, size int, concurrent int, duration time.Duration) []madmin.SpeedtestResult { - results := make([]madmin.SpeedtestResult, len(sys.peerClients)+1) + results := make([]madmin.SpeedtestResult, len(sys.allPeerClients)) scheme := "http" if globalIsTLS { @@ -1494,7 +1494,11 @@ func (sys *NotificationSys) Speedtest(ctx context.Context, size int, concurrent go func() { defer wg.Done() r, err := selfSpeedtest(ctx, size, concurrent, duration) - results[len(results)-1].Endpoint = globalMinioEndpoint + u := &url.URL{ + Scheme: scheme, + Host: globalLocalNodeName, + } + results[len(results)-1].Endpoint = u.String() results[len(results)-1].Err = err if err == nil { results[len(results)-1].Uploads = r.Uploads