From 786585009e9e84214d2caf982e1f71508442817b Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Thu, 4 Mar 2021 10:07:05 -0800 Subject: [PATCH] fix: capture disks when entire peer is offline (#11697) currently when one of the peer is down, the drives from that peer are reported as '0/0' offline instead we should capture/filter the drives from the peer and populate it appropriately such that `mc admin info` displays correct info. --- cmd/notification.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/cmd/notification.go b/cmd/notification.go index 8f1020cd0..ee574e457 100644 --- a/cmd/notification.go +++ b/cmd/notification.go @@ -1218,6 +1218,21 @@ func (sys *NotificationSys) ProcInfo(ctx context.Context) []madmin.ServerProcInf return reply } +func getOfflineDisks(offlineHost string, endpoints EndpointServerPools) []madmin.Disk { + var offlineDisks []madmin.Disk + for _, pool := range endpoints { + for _, ep := range pool.Endpoints { + if offlineHost == ep.Host { + offlineDisks = append(offlineDisks, madmin.Disk{ + Endpoint: ep.String(), + State: string(madmin.ItemOffline), + }) + } + } + } + return offlineDisks +} + // ServerInfo - calls ServerInfo RPC call on all peers. func (sys *NotificationSys) ServerInfo() []madmin.ServerProperties { reply := make([]madmin.ServerProperties, len(sys.peerClients)) @@ -1233,6 +1248,7 @@ func (sys *NotificationSys) ServerInfo() []madmin.ServerProperties { if err != nil { info.Endpoint = client.host.String() info.State = string(madmin.ItemOffline) + info.Disks = getOfflineDisks(info.Endpoint, globalEndpoints) } else { info.State = string(madmin.ItemOnline) }