Skip to content

Commit

Permalink
Better reporting of total/free usable capacity of the cluster
Browse files Browse the repository at this point in the history
The current code uses approximation using a ratio. The approximation can
skrew if we have multiple pools with different disk capacity.

Replace the algorithm with a simpler one which counts data disks and
ignore parity disks.
  • Loading branch information
Anis Elleuch committed Jul 5, 2022
1 parent c7e01b1 commit 92b7e4c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 24 deletions.
1 change: 1 addition & 0 deletions cmd/erasure-server-pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ func (z *erasureServerPools) GetRawData(ctx context.Context, volume, file string
return nil
}

// Return the count of disks in each pool
func (z *erasureServerPools) SetDriveCounts() []int {
setDriveCounts := make([]int, len(z.serverPools))
for i := range z.serverPools {
Expand Down
4 changes: 2 additions & 2 deletions cmd/metrics-v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -1904,12 +1904,12 @@ func getClusterStorageMetrics() *MetricsGroup {

metrics = append(metrics, Metric{
Description: getClusterCapacityUsageBytesMD(),
Value: GetTotalUsableCapacity(storageInfo.Disks, storageInfo),
Value: float64(GetTotalUsableCapacity(storageInfo.Disks, storageInfo)),
})

metrics = append(metrics, Metric{
Description: getClusterCapacityUsageFreeBytesMD(),
Value: GetTotalUsableCapacityFree(storageInfo.Disks, storageInfo),
Value: float64(GetTotalUsableCapacityFree(storageInfo.Disks, storageInfo)),
})

metrics = append(metrics, Metric{
Expand Down
4 changes: 2 additions & 2 deletions cmd/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ func storageMetricsPrometheus(ch chan<- prometheus.Metric) {
"Total usable capacity online in the cluster",
nil, nil),
prometheus.GaugeValue,
GetTotalUsableCapacity(server.Disks, s),
float64(GetTotalUsableCapacity(server.Disks, s)),
)
// Report total usable capacity free
ch <- prometheus.MustNewConstMetric(
Expand All @@ -586,7 +586,7 @@ func storageMetricsPrometheus(ch chan<- prometheus.Metric) {
"Total free usable capacity online in the cluster",
nil, nil),
prometheus.GaugeValue,
GetTotalUsableCapacityFree(server.Disks, s),
float64(GetTotalUsableCapacityFree(server.Disks, s)),
)

// MinIO Offline Disks per node
Expand Down
34 changes: 14 additions & 20 deletions cmd/notification-summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,14 @@ 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) {
for _, disk := range diskInfo {
// Ignore parity disks
if disk.DiskIndex < s.Backend.StandardSCData[disk.PoolIndex] {
capacity += disk.TotalSpace
}
}
ratio := approxDataBlocks / actualDisks
return float64(raw) * ratio
return
}

// GetTotalCapacityFree gets the total capacity free in the cluster.
Expand All @@ -52,15 +49,12 @@ 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) {
for _, disk := range diskInfo {
// Ignore parity disks
if disk.DiskIndex < s.Backend.StandardSCData[disk.PoolIndex] {
capacity += disk.AvailableSpace
}
}
ratio := approxDataBlocks / actualDisks
return float64(raw) * ratio
return
}

0 comments on commit 92b7e4c

Please sign in to comment.