Skip to content

Commit

Permalink
progressively report obd results (minio#9639)
Browse files Browse the repository at this point in the history
  • Loading branch information
wlan0 authored May 23, 2020
1 parent 43c19a6 commit c121d27
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 4 deletions.
19 changes: 15 additions & 4 deletions cmd/admin-handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
65 changes: 65 additions & 0 deletions cmd/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit c121d27

Please sign in to comment.