in pkg/csi_driver/controller.go [273:314]
func getRequestCapacity(capRange *csi.CapacityRange) (int64, error) {
var capBytes int64
// Default case where nothing is set
if capRange == nil {
capBytes = MinVolumeSizeBytes
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 < MinVolumeSizeBytes {
return 0, fmt.Errorf("limit bytes %v is less than minimum volume size: %v", lBytes, MinVolumeSizeBytes)
}
// If Required set just set capacity to that which is Required
if rSet {
capBytes = rBytes
}
// Lustre supports a 1 TiB thin instance for testing purposes.
// A thin instance will be created only when the capacity is set exactly to 1 TiB.
if capBytes == thinInstanceSizeBytyes {
return capBytes, nil
}
// Too large or too small.
if capBytes < MinVolumeSizeBytes {
capBytes = MinVolumeSizeBytes
}
if capBytes > MaxVolumeSizeBytes {
capBytes = MaxVolumeSizeBytes
}
return capBytes, nil
}