mirror of
https://github.com/minio/minio.git
synced 2025-11-07 12:52:58 -05:00
Better reporting of total/free usable capacity of the cluster (#15230)
The current code uses approximation using a ratio. The approximation can skew if we have multiple pools with different disk capacities. Replace the algorithm with a simpler one which counts data disks and ignore parity disks.
This commit is contained in:
@@ -30,17 +30,17 @@ func GetTotalCapacity(diskInfo []madmin.Disk) (capacity uint64) {
|
||||
}
|
||||
|
||||
// GetTotalUsableCapacity gets the total usable capacity in the cluster.
|
||||
// This value is not an accurate representation of total usable in a multi-tenant deployment.
|
||||
func GetTotalUsableCapacity(diskInfo []madmin.Disk, s StorageInfo) (capacity float64) {
|
||||
raw := GetTotalCapacity(diskInfo)
|
||||
var approxDataBlocks float64
|
||||
var actualDisks float64
|
||||
for _, scData := range s.Backend.StandardSCData {
|
||||
approxDataBlocks += float64(scData)
|
||||
actualDisks += float64(scData + s.Backend.StandardSCParity)
|
||||
func GetTotalUsableCapacity(diskInfo []madmin.Disk, s StorageInfo) (capacity uint64) {
|
||||
if globalIsGateway {
|
||||
return 0
|
||||
}
|
||||
ratio := approxDataBlocks / actualDisks
|
||||
return float64(raw) * ratio
|
||||
for _, disk := range diskInfo {
|
||||
// Ignore parity disks
|
||||
if disk.DiskIndex < s.Backend.StandardSCData[disk.PoolIndex] {
|
||||
capacity += disk.TotalSpace
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// GetTotalCapacityFree gets the total capacity free in the cluster.
|
||||
@@ -52,15 +52,16 @@ func GetTotalCapacityFree(diskInfo []madmin.Disk) (capacity uint64) {
|
||||
}
|
||||
|
||||
// GetTotalUsableCapacityFree gets the total usable capacity free in the cluster.
|
||||
// This value is not an accurate representation of total free in a multi-tenant deployment.
|
||||
func GetTotalUsableCapacityFree(diskInfo []madmin.Disk, s StorageInfo) (capacity float64) {
|
||||
raw := GetTotalCapacityFree(diskInfo)
|
||||
var approxDataBlocks float64
|
||||
var actualDisks float64
|
||||
for _, scData := range s.Backend.StandardSCData {
|
||||
approxDataBlocks += float64(scData)
|
||||
actualDisks += float64(scData + s.Backend.StandardSCParity)
|
||||
func GetTotalUsableCapacityFree(diskInfo []madmin.Disk, s StorageInfo) (capacity uint64) {
|
||||
if globalIsGateway {
|
||||
return 0
|
||||
}
|
||||
ratio := approxDataBlocks / actualDisks
|
||||
return float64(raw) * ratio
|
||||
|
||||
for _, disk := range diskInfo {
|
||||
// Ignore parity disks
|
||||
if disk.DiskIndex < s.Backend.StandardSCData[disk.PoolIndex] {
|
||||
capacity += disk.AvailableSpace
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user