mirror of
https://github.com/minio/minio.git
synced 2025-04-07 13:15:39 -04:00
Fix GetLocalPeer usage in perf handlers (#7249)
GetLocalPeer usage should be fixed and used only once per call for not all local endpoints.
This commit is contained in:
parent
3aabe45fd9
commit
91576d416d
@ -205,7 +205,6 @@ func (endpoints EndpointList) GetString(i int) string {
|
|||||||
func localEndpointsMemUsage(endpoints EndpointList) ServerMemUsageInfo {
|
func localEndpointsMemUsage(endpoints EndpointList) ServerMemUsageInfo {
|
||||||
var memUsages []mem.Usage
|
var memUsages []mem.Usage
|
||||||
var historicUsages []mem.Usage
|
var historicUsages []mem.Usage
|
||||||
var addr string
|
|
||||||
scratchSpace := map[string]bool{}
|
scratchSpace := map[string]bool{}
|
||||||
for _, endpoint := range endpoints {
|
for _, endpoint := range endpoints {
|
||||||
// Only proceed for local endpoints
|
// Only proceed for local endpoints
|
||||||
@ -213,16 +212,13 @@ func localEndpointsMemUsage(endpoints EndpointList) ServerMemUsageInfo {
|
|||||||
if _, ok := scratchSpace[endpoint.Host]; ok {
|
if _, ok := scratchSpace[endpoint.Host]; ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
addr = GetLocalPeer(endpoints)
|
memUsages = append(memUsages, mem.GetUsage())
|
||||||
memUsage := mem.GetUsage()
|
historicUsages = append(historicUsages, mem.GetHistoricUsage())
|
||||||
memUsages = append(memUsages, memUsage)
|
|
||||||
historicUsage := mem.GetHistoricUsage()
|
|
||||||
historicUsages = append(historicUsages, historicUsage)
|
|
||||||
scratchSpace[endpoint.Host] = true
|
scratchSpace[endpoint.Host] = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ServerMemUsageInfo{
|
return ServerMemUsageInfo{
|
||||||
Addr: addr,
|
Addr: GetLocalPeer(endpoints),
|
||||||
Usage: memUsages,
|
Usage: memUsages,
|
||||||
HistoricUsage: historicUsages,
|
HistoricUsage: historicUsages,
|
||||||
}
|
}
|
||||||
@ -233,7 +229,6 @@ func localEndpointsMemUsage(endpoints EndpointList) ServerMemUsageInfo {
|
|||||||
func localEndpointsCPULoad(endpoints EndpointList) ServerCPULoadInfo {
|
func localEndpointsCPULoad(endpoints EndpointList) ServerCPULoadInfo {
|
||||||
var cpuLoads []cpu.Load
|
var cpuLoads []cpu.Load
|
||||||
var historicLoads []cpu.Load
|
var historicLoads []cpu.Load
|
||||||
var addr string
|
|
||||||
scratchSpace := map[string]bool{}
|
scratchSpace := map[string]bool{}
|
||||||
for _, endpoint := range endpoints {
|
for _, endpoint := range endpoints {
|
||||||
// Only proceed for local endpoints
|
// Only proceed for local endpoints
|
||||||
@ -241,16 +236,13 @@ func localEndpointsCPULoad(endpoints EndpointList) ServerCPULoadInfo {
|
|||||||
if _, ok := scratchSpace[endpoint.Host]; ok {
|
if _, ok := scratchSpace[endpoint.Host]; ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
addr = GetLocalPeer(endpoints)
|
cpuLoads = append(cpuLoads, cpu.GetLoad())
|
||||||
cpuLoad := cpu.GetLoad()
|
historicLoads = append(historicLoads, cpu.GetHistoricLoad())
|
||||||
cpuLoads = append(cpuLoads, cpuLoad)
|
|
||||||
historicLoad := cpu.GetHistoricLoad()
|
|
||||||
historicLoads = append(historicLoads, historicLoad)
|
|
||||||
scratchSpace[endpoint.Host] = true
|
scratchSpace[endpoint.Host] = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ServerCPULoadInfo{
|
return ServerCPULoadInfo{
|
||||||
Addr: addr,
|
Addr: GetLocalPeer(endpoints),
|
||||||
Load: cpuLoads,
|
Load: cpuLoads,
|
||||||
HistoricLoad: historicLoads,
|
HistoricLoad: historicLoads,
|
||||||
}
|
}
|
||||||
@ -260,26 +252,22 @@ func localEndpointsCPULoad(endpoints EndpointList) ServerCPULoadInfo {
|
|||||||
// local endpoints from given list of endpoints
|
// local endpoints from given list of endpoints
|
||||||
func localEndpointsDrivePerf(endpoints EndpointList) ServerDrivesPerfInfo {
|
func localEndpointsDrivePerf(endpoints EndpointList) ServerDrivesPerfInfo {
|
||||||
var dps []disk.Performance
|
var dps []disk.Performance
|
||||||
var addr string
|
|
||||||
for _, endpoint := range endpoints {
|
for _, endpoint := range endpoints {
|
||||||
// Only proceed for local endpoints
|
// Only proceed for local endpoints
|
||||||
if endpoint.IsLocal {
|
if endpoint.IsLocal {
|
||||||
addr = GetLocalPeer(endpoints)
|
|
||||||
if _, err := os.Stat(endpoint.Path); err != nil {
|
if _, err := os.Stat(endpoint.Path); err != nil {
|
||||||
// Since this drive is not available, add relevant details and proceed
|
// Since this drive is not available, add relevant details and proceed
|
||||||
dps = append(dps, disk.Performance{Path: endpoint.Path, Error: err.Error()})
|
dps = append(dps, disk.Performance{Path: endpoint.Path, Error: err.Error()})
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
tempObj := mustGetUUID()
|
dp := disk.GetPerformance(pathJoin(endpoint.Path, minioMetaTmpBucket, mustGetUUID()))
|
||||||
fsPath := pathJoin(endpoint.Path, minioMetaTmpBucket, tempObj)
|
|
||||||
dp := disk.GetPerformance(fsPath)
|
|
||||||
dp.Path = endpoint.Path
|
dp.Path = endpoint.Path
|
||||||
dps = append(dps, dp)
|
dps = append(dps, dp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ServerDrivesPerfInfo{
|
return ServerDrivesPerfInfo{
|
||||||
Addr: addr,
|
Addr: GetLocalPeer(endpoints),
|
||||||
Perf: dps,
|
Perf: dps,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user