in pkg/csi_driver/controller.go [247:280]
func getRequestCapacity(capRange *csi.CapacityRange) (int64, error) {
var capBytes int64
// Default case where nothing is set
if capRange == nil {
capBytes = MinimumVolumeSizeInBytes
return capBytes, nil
}
rBytes := capRange.GetRequiredBytes()
rSet := rBytes > 0
lBytes := capRange.GetLimitBytes()
lSet := lBytes > 0
if lSet && rSet && lBytes < rBytes {
return 0, fmt.Errorf("limit bytes %v is less than required bytes %v", lBytes, rBytes)
}
if lSet && lBytes < MinimumVolumeSizeInBytes {
return 0, fmt.Errorf("limit bytes %v is less than minimum volume size: %v", lBytes, MinimumVolumeSizeInBytes)
}
// If Required set just set capacity to that which is Required
if rSet {
capBytes = rBytes
}
// Limit is more than Required, but larger than Minimum. So we just set capcity to Minimum
// Too small, default
if capBytes < MinimumVolumeSizeInBytes {
capBytes = MinimumVolumeSizeInBytes
}
return capBytes, nil
}