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.
This commit is contained in:
Shireesh Anjal 2021-03-01 21:39:43 +05:30 committed by GitHub
parent 0b9c17443e
commit 289b22d911
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 14 deletions

View File

@ -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)

View File

@ -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
}