mirror of
https://github.com/minio/minio.git
synced 2024-12-24 22:25:54 -05:00
ServerInfo: return per erasure set information (#16583)
This commit is contained in:
parent
bf749eec61
commit
689179bf18
@ -1776,7 +1776,43 @@ func (a adminAPIHandlers) KMSKeyStatusHandler(w http.ResponseWriter, r *http.Req
|
|||||||
writeSuccessResponseJSON(w, resp)
|
writeSuccessResponseJSON(w, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getServerInfo(ctx context.Context, r *http.Request) madmin.InfoMessage {
|
func getPoolsInfo(ctx context.Context, allDisks []madmin.Disk) (map[int]map[int]madmin.ErasureSetInfo, error) {
|
||||||
|
objectAPI := newObjectLayerFn()
|
||||||
|
if objectAPI == nil {
|
||||||
|
return nil, errServerNotInitialized
|
||||||
|
}
|
||||||
|
|
||||||
|
z, _ := objectAPI.(*erasureServerPools)
|
||||||
|
|
||||||
|
poolsInfo := make(map[int]map[int]madmin.ErasureSetInfo)
|
||||||
|
for _, d := range allDisks {
|
||||||
|
poolInfo, ok := poolsInfo[d.PoolIndex]
|
||||||
|
if !ok {
|
||||||
|
poolInfo = make(map[int]madmin.ErasureSetInfo)
|
||||||
|
}
|
||||||
|
erasureSet, ok := poolInfo[d.SetIndex]
|
||||||
|
if !ok {
|
||||||
|
erasureSet.ID = d.SetIndex
|
||||||
|
cache := dataUsageCache{}
|
||||||
|
if err := cache.load(ctx, z.serverPools[d.PoolIndex].sets[d.SetIndex], dataUsageCacheName); err == nil {
|
||||||
|
dataUsageInfo := cache.dui(dataUsageRoot, nil)
|
||||||
|
erasureSet.ObjectsCount = dataUsageInfo.ObjectsTotalCount
|
||||||
|
erasureSet.VersionsCount = dataUsageInfo.VersionsTotalCount
|
||||||
|
erasureSet.Usage = dataUsageInfo.ObjectsTotalSize
|
||||||
|
}
|
||||||
|
}
|
||||||
|
erasureSet.RawCapacity += d.TotalSpace
|
||||||
|
erasureSet.RawUsage += d.UsedSpace
|
||||||
|
if d.Healing {
|
||||||
|
erasureSet.HealDisks = 1
|
||||||
|
}
|
||||||
|
poolInfo[d.SetIndex] = erasureSet
|
||||||
|
poolsInfo[d.PoolIndex] = poolInfo
|
||||||
|
}
|
||||||
|
return poolsInfo, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func getServerInfo(ctx context.Context, poolsInfoEnabled bool, r *http.Request) madmin.InfoMessage {
|
||||||
kmsStat := fetchKMSStatus()
|
kmsStat := fetchKMSStatus()
|
||||||
|
|
||||||
ldap := madmin.LDAP{}
|
ldap := madmin.LDAP{}
|
||||||
@ -1805,7 +1841,9 @@ func getServerInfo(ctx context.Context, r *http.Request) madmin.InfoMessage {
|
|||||||
|
|
||||||
assignPoolNumbers(servers)
|
assignPoolNumbers(servers)
|
||||||
|
|
||||||
|
var poolsInfo map[int]map[int]madmin.ErasureSetInfo
|
||||||
var backend interface{}
|
var backend interface{}
|
||||||
|
|
||||||
mode := madmin.ItemInitializing
|
mode := madmin.ItemInitializing
|
||||||
|
|
||||||
buckets := madmin.Buckets{}
|
buckets := madmin.Buckets{}
|
||||||
@ -1832,7 +1870,6 @@ func getServerInfo(ctx context.Context, r *http.Request) madmin.InfoMessage {
|
|||||||
|
|
||||||
// Fetching the backend information
|
// Fetching the backend information
|
||||||
backendInfo := objectAPI.BackendInfo()
|
backendInfo := objectAPI.BackendInfo()
|
||||||
if backendInfo.Type == madmin.Erasure {
|
|
||||||
// Calculate the number of online/offline disks of all nodes
|
// Calculate the number of online/offline disks of all nodes
|
||||||
var allDisks []madmin.Disk
|
var allDisks []madmin.Disk
|
||||||
for _, s := range servers {
|
for _, s := range servers {
|
||||||
@ -1847,10 +1884,9 @@ func getServerInfo(ctx context.Context, r *http.Request) madmin.InfoMessage {
|
|||||||
StandardSCParity: backendInfo.StandardSCParity,
|
StandardSCParity: backendInfo.StandardSCParity,
|
||||||
RRSCParity: backendInfo.RRSCParity,
|
RRSCParity: backendInfo.RRSCParity,
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
backend = madmin.FSBackend{
|
if poolsInfoEnabled {
|
||||||
Type: madmin.FsType,
|
poolsInfo, _ = getPoolsInfo(ctx, allDisks)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1876,6 +1912,7 @@ func getServerInfo(ctx context.Context, r *http.Request) madmin.InfoMessage {
|
|||||||
Services: services,
|
Services: services,
|
||||||
Backend: backend,
|
Backend: backend,
|
||||||
Servers: servers,
|
Servers: servers,
|
||||||
|
Pools: poolsInfo,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2182,7 +2219,7 @@ func fetchHealthInfo(healthCtx context.Context, objectAPI ObjectLayer, query *ur
|
|||||||
getAndWriteSysConfig()
|
getAndWriteSysConfig()
|
||||||
|
|
||||||
if query.Get("minioinfo") == "true" {
|
if query.Get("minioinfo") == "true" {
|
||||||
infoMessage := getServerInfo(healthCtx, nil)
|
infoMessage := getServerInfo(healthCtx, false, nil)
|
||||||
servers := make([]madmin.ServerInfo, 0, len(infoMessage.Servers))
|
servers := make([]madmin.ServerInfo, 0, len(infoMessage.Servers))
|
||||||
for _, server := range infoMessage.Servers {
|
for _, server := range infoMessage.Servers {
|
||||||
anonEndpoint := anonAddr(server.Endpoint)
|
anonEndpoint := anonAddr(server.Endpoint)
|
||||||
@ -2357,7 +2394,7 @@ func (a adminAPIHandlers) ServerInfoHandler(w http.ResponseWriter, r *http.Reque
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Marshal API response
|
// Marshal API response
|
||||||
jsonBytes, err := json.Marshal(getServerInfo(ctx, r))
|
jsonBytes, err := json.Marshal(getServerInfo(ctx, true, r))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
||||||
return
|
return
|
||||||
|
2
go.mod
2
go.mod
@ -48,7 +48,7 @@ require (
|
|||||||
github.com/minio/dperf v0.4.2
|
github.com/minio/dperf v0.4.2
|
||||||
github.com/minio/highwayhash v1.0.2
|
github.com/minio/highwayhash v1.0.2
|
||||||
github.com/minio/kes v0.22.3
|
github.com/minio/kes v0.22.3
|
||||||
github.com/minio/madmin-go/v2 v2.0.9
|
github.com/minio/madmin-go/v2 v2.0.11
|
||||||
github.com/minio/minio-go/v7 v7.0.47
|
github.com/minio/minio-go/v7 v7.0.47
|
||||||
github.com/minio/mux v1.9.0
|
github.com/minio/mux v1.9.0
|
||||||
github.com/minio/pkg v1.6.1
|
github.com/minio/pkg v1.6.1
|
||||||
|
4
go.sum
4
go.sum
@ -775,8 +775,8 @@ github.com/minio/highwayhash v1.0.2/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLT
|
|||||||
github.com/minio/kes v0.22.3 h1:aSPW9uCMVaLax5POxvoQJxCU4MNo/KzMXA7WfmC/lRw=
|
github.com/minio/kes v0.22.3 h1:aSPW9uCMVaLax5POxvoQJxCU4MNo/KzMXA7WfmC/lRw=
|
||||||
github.com/minio/kes v0.22.3/go.mod h1:wnhmdwWX2rpurNPKn3yDFImg2wuc7j3e+IU5rVkR9UY=
|
github.com/minio/kes v0.22.3/go.mod h1:wnhmdwWX2rpurNPKn3yDFImg2wuc7j3e+IU5rVkR9UY=
|
||||||
github.com/minio/madmin-go v1.6.6/go.mod h1:ATvkBOLiP3av4D++2v1UEHC/QzsGtgXD5kYvvRYzdKs=
|
github.com/minio/madmin-go v1.6.6/go.mod h1:ATvkBOLiP3av4D++2v1UEHC/QzsGtgXD5kYvvRYzdKs=
|
||||||
github.com/minio/madmin-go/v2 v2.0.9 h1:wv1e4ZTH1L1SaHs/jaI3uW2AHYQw77T2hgarfPo1j3U=
|
github.com/minio/madmin-go/v2 v2.0.11 h1:Ct905UAMJ43EAwKCi8xy5PzWPWyYL5YCQ441E9LYXTA=
|
||||||
github.com/minio/madmin-go/v2 v2.0.9/go.mod h1:5aFi/VLWBHC2DEFfGIlUmAeJhaF4ZAjuYpEWZFU14Zw=
|
github.com/minio/madmin-go/v2 v2.0.11/go.mod h1:5aFi/VLWBHC2DEFfGIlUmAeJhaF4ZAjuYpEWZFU14Zw=
|
||||||
github.com/minio/mc v0.0.0-20230203133213-3aebb3362b18 h1:Di71Ums7dD5vA3VK/loOqb/QttQjvCV/1/DF77w1XqA=
|
github.com/minio/mc v0.0.0-20230203133213-3aebb3362b18 h1:Di71Ums7dD5vA3VK/loOqb/QttQjvCV/1/DF77w1XqA=
|
||||||
github.com/minio/mc v0.0.0-20230203133213-3aebb3362b18/go.mod h1:j3BgTu1LshBzna9Wf8il7WAyw9IQabMu+EcrDUaNZ2k=
|
github.com/minio/mc v0.0.0-20230203133213-3aebb3362b18/go.mod h1:j3BgTu1LshBzna9Wf8il7WAyw9IQabMu+EcrDUaNZ2k=
|
||||||
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
|
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
|
||||||
|
Loading…
Reference in New Issue
Block a user