From c121d27f314274c15bbc20a74922a8562daba1fa Mon Sep 17 00:00:00 2001 From: Sidhartha Mani Date: Fri, 22 May 2020 17:56:45 -0700 Subject: [PATCH] progressively report obd results (#9639) --- cmd/admin-handlers.go | 19 ++++++++++--- cmd/notification.go | 65 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 4 deletions(-) diff --git a/cmd/admin-handlers.go b/cmd/admin-handlers.go index 9a2e8d6f9..fefd0eed5 100644 --- a/cmd/admin-handlers.go +++ b/cmd/admin-handlers.go @@ -1252,17 +1252,28 @@ func (a adminAPIHandlers) OBDInfoHandler(w http.ResponseWriter, r *http.Request) Error: errStr, } obdInfo.Perf.DriveInfo = append(obdInfo.Perf.DriveInfo, driveOBD) + partialWrite(obdInfo) // Notify all other MinIO peers to report drive obd numbers - driveOBDs := globalNotificationSys.DriveOBDInfo(deadlinedCtx) - obdInfo.Perf.DriveInfo = append(obdInfo.Perf.DriveInfo, driveOBDs...) - + driveOBDs := globalNotificationSys.DriveOBDInfoChan(deadlinedCtx) + for obd := range driveOBDs { + obdInfo.Perf.DriveInfo = append(obdInfo.Perf.DriveInfo, obd) + partialWrite(obdInfo) + } partialWrite(obdInfo) } if net, ok := vars["perfnet"]; ok && net == "true" && globalIsDistXL { obdInfo.Perf.Net = append(obdInfo.Perf.Net, globalNotificationSys.NetOBDInfo(deadlinedCtx)) - obdInfo.Perf.Net = append(obdInfo.Perf.Net, globalNotificationSys.DispatchNetOBDInfo(deadlinedCtx)...) + partialWrite(obdInfo) + + netOBDs := globalNotificationSys.DispatchNetOBDChan(deadlinedCtx) + for obd := range netOBDs { + obdInfo.Perf.Net = append(obdInfo.Perf.Net, obd) + partialWrite(obdInfo) + } + partialWrite(obdInfo) + obdInfo.Perf.NetParallel = globalNotificationSys.NetOBDParallelInfo(deadlinedCtx) partialWrite(obdInfo) } diff --git a/cmd/notification.go b/cmd/notification.go index e1e0b29ea..3207f1743 100644 --- a/cmd/notification.go +++ b/cmd/notification.go @@ -864,6 +864,35 @@ func (sys *NotificationSys) DispatchNetOBDInfo(ctx context.Context) []madmin.Ser return serverNetOBDs } +// DispatchNetOBDChan - Net OBD information from other nodes +func (sys *NotificationSys) DispatchNetOBDChan(ctx context.Context) chan madmin.ServerNetOBDInfo { + serverNetOBDs := make(chan madmin.ServerNetOBDInfo) + wg := sync.WaitGroup{} + + wg.Add(1) + go func() { + for _, client := range sys.peerClients { + if client == nil { + continue + } + serverNetOBD, err := client.DispatchNetOBDInfo(ctx) + if err != nil { + serverNetOBD.Addr = client.host.String() + serverNetOBD.Error = err.Error() + } + serverNetOBDs <- serverNetOBD + } + wg.Done() + }() + + go func() { + wg.Wait() + close(serverNetOBDs) + }() + + return serverNetOBDs +} + // NetOBDParallelInfo - Performs NetOBD tests func (sys *NotificationSys) NetOBDParallelInfo(ctx context.Context) madmin.ServerNetOBDInfo { netOBDs := []madmin.NetOBDInfo{} @@ -923,6 +952,42 @@ func (sys *NotificationSys) DriveOBDInfo(ctx context.Context) []madmin.ServerDri return reply } +// DriveOBDInfoChan - Drive OBD information +func (sys *NotificationSys) DriveOBDInfoChan(ctx context.Context) chan madmin.ServerDrivesOBDInfo { + updateChan := make(chan madmin.ServerDrivesOBDInfo) + wg := sync.WaitGroup{} + + for _, client := range sys.peerClients { + if client == nil { + continue + } + wg.Add(1) + go func(client *peerRESTClient) { + reply, err := client.DriveOBDInfo(ctx) + + addr := client.host.String() + reqInfo := (&logger.ReqInfo{}).AppendTags("remotePeer", addr) + ctx := logger.SetReqInfo(GlobalContext, reqInfo) + logger.LogIf(ctx, err) + + reply.Addr = addr + if err != nil { + reply.Error = err.Error() + } + + updateChan <- reply + wg.Done() + }(client) + } + + go func() { + wg.Wait() + close(updateChan) + }() + + return updateChan +} + // CPUOBDInfo - CPU OBD information func (sys *NotificationSys) CPUOBDInfo(ctx context.Context) []madmin.ServerCPUOBDInfo { reply := make([]madmin.ServerCPUOBDInfo, len(sys.peerClients))