[shell]: volume balance capacity by min volume density (#8026)

volume balance by min volume density and active volumes
This commit is contained in:
Konstantin Lebedev
2026-02-20 02:30:59 +05:00
committed by GitHub
parent 7b8df39cf7
commit 01b3125815
6 changed files with 149 additions and 32 deletions

View File

@@ -262,3 +262,5 @@ const (
PByte = TByte * 1000
EByte = PByte * 1000
)
const ErrVolumeNoSpaceLeft = "no space left for disk type"

View File

@@ -44,6 +44,20 @@ func (s MinFreeSpace) IsLow(freeBytes uint64, freePercent float32) (yes bool, de
return false, ""
}
func (s MinFreeSpace) AvailableSpace(freeBytes uint64, totalBytes uint64) uint64 {
var minFreeSpaceBytes uint64
switch s.Type {
case AsPercent:
minFreeSpaceBytes = uint64((float32(totalBytes) * s.Percent) / 100)
case AsBytes:
minFreeSpaceBytes = s.Bytes
}
if minFreeSpaceBytes > freeBytes {
return 0
}
return freeBytes - minFreeSpaceBytes
}
// String returns a string representation of MinFreeSpace.
func (s MinFreeSpace) String() string {
switch s.Type {