mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-09 16:00:22 +00:00
cephfs: Fix cephfs PVC sizing
Issue: The RoundOffCephFSVolSize() function omits the fractional part when calculating the size for cephfs volumes, leading to the created volume capacity to be lesser than the requested volume capacity. Fix: Consider the fractional part during the size calculation so the rounded off volume size will be greater than or equal to the requested volume size. Signed-off-by: karthik-us <ksubrahm@redhat.com> Fixes: #4179
This commit is contained in:
parent
e79b963644
commit
5a0eeb882e
@ -67,9 +67,9 @@ func RoundOffCephFSVolSize(bytes int64) int64 {
|
||||
return 4 * helpers.MiB
|
||||
}
|
||||
|
||||
bytes /= helpers.MiB
|
||||
floatbytes := float64(bytes) / helpers.MiB
|
||||
|
||||
bytes = int64(math.Ceil(float64(bytes)/4) * 4)
|
||||
bytes = int64(math.Ceil(floatbytes/4) * 4)
|
||||
|
||||
return RoundOffBytes(bytes * helpers.MiB)
|
||||
}
|
||||
|
@ -375,6 +375,16 @@ func TestRoundOffCephFSVolSize(t *testing.T) {
|
||||
1677722,
|
||||
4194304, // 4 MiB
|
||||
},
|
||||
{
|
||||
"101MB conversion",
|
||||
101000000,
|
||||
104857600, // 100MiB
|
||||
},
|
||||
{
|
||||
"500MB conversion",
|
||||
500000000,
|
||||
503316480, // 480MiB
|
||||
},
|
||||
{
|
||||
"1023MiB conversion",
|
||||
1072693248,
|
||||
|
Loading…
Reference in New Issue
Block a user