From 289b22d9117cc7ce321d6714d7daf50d3da6b50a Mon Sep 17 00:00:00 2001 From: Shireesh Anjal <355479+anjalshireesh@users.noreply.github.com> Date: Mon, 1 Mar 2021 21:39:43 +0530 Subject: [PATCH] fix: pool number not added for one server (#11670) The previous code was iterating over replies from peers and assigning pool numbers to them, thus missing to add it for the local server. Fixed by iterating over the server properties of all the servers including the local one. --- cmd/admin-handlers.go | 18 ++++++++++++++++++ cmd/notification.go | 14 -------------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/cmd/admin-handlers.go b/cmd/admin-handlers.go index dd8eedf1c..32ebd6732 100644 --- a/cmd/admin-handlers.go +++ b/cmd/admin-handlers.go @@ -1570,6 +1570,8 @@ func (a adminAPIHandlers) ServerInfoHandler(w http.ResponseWriter, r *http.Reque servers := globalNotificationSys.ServerInfo() servers = append(servers, server) + assignPoolNumbers(servers) + var backend interface{} mode := madmin.ObjectLayerInitializing @@ -1651,6 +1653,22 @@ func (a adminAPIHandlers) ServerInfoHandler(w http.ResponseWriter, r *http.Reque writeSuccessResponseJSON(w, jsonBytes) } +func assignPoolNumbers(servers []madmin.ServerProperties) { + for i := range servers { + for idx, ge := range globalEndpoints { + for _, endpoint := range ge.Endpoints { + if servers[i].Endpoint == endpoint.Host { + servers[i].PoolNumber = idx + 1 + } else if host, err := xnet.ParseHost(servers[i].Endpoint); err == nil { + if host.Name == endpoint.Hostname() { + servers[i].PoolNumber = idx + 1 + } + } + } + } + } +} + func fetchLambdaInfo() []map[string][]madmin.TargetIDStatus { lambdaMap := make(map[string][]madmin.TargetIDStatus) diff --git a/cmd/notification.go b/cmd/notification.go index e255b8464..8ecd4933e 100644 --- a/cmd/notification.go +++ b/cmd/notification.go @@ -1240,20 +1240,6 @@ func (sys *NotificationSys) ServerInfo() []madmin.ServerProperties { } wg.Wait() - for i := range reply { - for j := range globalEndpoints { - for _, endpoint := range globalEndpoints[j].Endpoints { - if reply[i].Endpoint == endpoint.Host { - reply[i].PoolNumber = j + 1 - } else if host, err := xnet.ParseHost(reply[i].Endpoint); err == nil { - if host.Name == endpoint.Hostname() { - reply[i].PoolNumber = j + 1 - } - } - } - } - } - return reply }