Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better reporting of total/free usable capacity of the cluster #15230

Merged
merged 3 commits into from
Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/admin-handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -1189,7 +1189,7 @@ func deleteObjectPerfBucket(objectAPI ObjectLayer) {
func validateObjPerfOptions(ctx context.Context, objectAPI ObjectLayer, concurrent int, size int, autotune bool) (sufficientCapacity bool, canAutotune bool, capacityErrMsg string) {
storageInfo, _ := objectAPI.StorageInfo(ctx)
capacityNeeded := uint64(concurrent * size)
capacity := uint64(GetTotalUsableCapacityFree(storageInfo.Disks, storageInfo))
capacity := GetTotalUsableCapacityFree(storageInfo.Disks, storageInfo)

if capacity < capacityNeeded {
return false, false, fmt.Sprintf("not enough usable space available to perform speedtest - expected %s, got %s",
Expand Down
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: 4 additions & 0 deletions cmd/erasure-single-drive.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ func (es *erasureSingle) Shutdown(ctx context.Context) error {
return nil
}

func (es *erasureSingle) SetDriveCounts() []int {
return []int{1}
}

func (es *erasureSingle) BackendInfo() (b madmin.BackendInfo) {
b.Type = madmin.Erasure

Expand Down
10 changes: 8 additions & 2 deletions cmd/fs-v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,13 @@ func (fs *FSObjects) Shutdown(ctx context.Context) error {

// BackendInfo - returns backend information
func (fs *FSObjects) BackendInfo() madmin.BackendInfo {
return madmin.BackendInfo{Type: madmin.FS}
return madmin.BackendInfo{
Type: madmin.FS,
StandardSCData: []int{1},
StandardSCParity: 0,
RRSCData: []int{1},
RRSCParity: 0,
}
}

// LocalStorageInfo - returns underlying storage statistics.
Expand All @@ -235,7 +241,7 @@ func (fs *FSObjects) StorageInfo(ctx context.Context) (StorageInfo, []error) {
},
},
}
storageInfo.Backend.Type = madmin.FS
storageInfo.Backend = fs.BackendInfo()
return storageInfo, nil
}

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
41 changes: 21 additions & 20 deletions cmd/notification-summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -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] {
harshavardhana marked this conversation as resolved.
Show resolved Hide resolved
capacity += disk.TotalSpace
}
}
return
}

// GetTotalCapacityFree gets the total capacity free in the cluster.
Expand All @@ -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 {
harshavardhana marked this conversation as resolved.
Show resolved Hide resolved
// Ignore parity disks
if disk.DiskIndex < s.Backend.StandardSCData[disk.PoolIndex] {
harshavardhana marked this conversation as resolved.
Show resolved Hide resolved
capacity += disk.AvailableSpace
}
}
return
}