server-info: Return initializing state properly (#17070)

This commit is contained in:
Anis Eleuch 2023-04-24 17:10:02 +01:00 committed by GitHub
parent 477230c82e
commit 6addc7a35d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -87,7 +87,6 @@ func getLocalServerProperty(endpointServerPools EndpointServerPools, r *http.Req
} }
props := madmin.ServerProperties{ props := madmin.ServerProperties{
State: string(madmin.ItemInitializing),
Endpoint: addr, Endpoint: addr,
Uptime: UTCNow().Unix() - globalBootTime.Unix(), Uptime: UTCNow().Unix() - globalBootTime.Unix(),
Version: Version, Version: Version,
@ -146,7 +145,8 @@ func getLocalServerProperty(endpointServerPools EndpointServerPools, r *http.Req
props.State = string(madmin.ItemOnline) props.State = string(madmin.ItemOnline)
props.Disks = storageInfo.Disks props.Disks = storageInfo.Disks
} else { } else {
props.State = string(madmin.ItemOffline) props.State = string(madmin.ItemInitializing)
props.Disks = getOfflineDisks("", globalEndpoints)
} }
return props return props

View File

@ -883,11 +883,13 @@ func (sys *NotificationSys) GetProcInfo(ctx context.Context) []madmin.ProcInfo {
return reply return reply
} }
// Construct a list of offline disks information for a given node.
// If offlineHost is empty, do it for the local disks.
func getOfflineDisks(offlineHost string, endpoints EndpointServerPools) []madmin.Disk { func getOfflineDisks(offlineHost string, endpoints EndpointServerPools) []madmin.Disk {
var offlineDisks []madmin.Disk var offlineDisks []madmin.Disk
for _, pool := range endpoints { for _, pool := range endpoints {
for _, ep := range pool.Endpoints { for _, ep := range pool.Endpoints {
if offlineHost == ep.Host { if offlineHost == "" && ep.IsLocal || offlineHost == ep.Host {
offlineDisks = append(offlineDisks, madmin.Disk{ offlineDisks = append(offlineDisks, madmin.Disk{
Endpoint: ep.String(), Endpoint: ep.String(),
State: string(madmin.ItemOffline), State: string(madmin.ItemOffline),
@ -947,8 +949,6 @@ func (sys *NotificationSys) ServerInfo() []madmin.ServerProperties {
info.Endpoint = client.host.String() info.Endpoint = client.host.String()
info.State = string(madmin.ItemOffline) info.State = string(madmin.ItemOffline)
info.Disks = getOfflineDisks(info.Endpoint, globalEndpoints) info.Disks = getOfflineDisks(info.Endpoint, globalEndpoints)
} else {
info.State = string(madmin.ItemOnline)
} }
reply[idx] = info reply[idx] = info
}(client, i) }(client, i)