File tree Expand file tree Collapse file tree 2 files changed +12
-7
lines changed Expand file tree Collapse file tree 2 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -573,9 +573,11 @@ func isCachingSetup(mainLvName string) (error, bool) {
573
573
return nil , false
574
574
}
575
575
576
+ // cacheSize is always in GiB
576
577
func fetchChunkSizeKiB (cacheSize string ) (string , error ) {
577
578
var chunkSize float64
578
579
580
+ cacheSize = strings .TrimSuffix (cacheSize , "GiB" )
579
581
cacheSizeInt , err := strconv .ParseInt (cacheSize , 10 , 64 )
580
582
if err != nil {
581
583
return "0" , err
@@ -691,10 +693,8 @@ func addRaidedLSSDToVg(vgName, lssdPath string) error {
691
693
692
694
func fetchPvSizeGiB () (string , error ) {
693
695
args := []string {
694
- "--select" ,
695
- "-o" ,
696
+ "-o" , "pv_name,pv_size" ,
696
697
"--noheadings" ,
697
- "pv_size" ,
698
698
"--units=b" ,
699
699
}
700
700
// RAIDed device is always registered with its /dev/md127 equivalent in VG so cannot check it directly based on the RAIDed LSSD path which could be /dev/md/csi-driver-data-cache
Original file line number Diff line number Diff line change @@ -13,24 +13,29 @@ func TestFetchChunkSizeKiB(t *testing.T) {
13
13
}{
14
14
{
15
15
name : "chunk size is in the allowed range" ,
16
- cacheSize : "500 " ,
16
+ cacheSize : "500GiB " ,
17
17
expChunkSize : "512KiB" , //range defined in fetchChunkSizeKiB
18
18
},
19
19
{
20
20
name : "chunk size is set to the range ceil" ,
21
- cacheSize : "30000000 " ,
21
+ cacheSize : "30000000GiB " ,
22
22
expChunkSize : "1048576KiB" , //range defined in fetchChunkSizeKiB - max 1GiB
23
23
},
24
24
{
25
25
name : "chunk size is set to the allowed range floor" ,
26
- cacheSize : "100 " ,
26
+ cacheSize : "100GiB " ,
27
27
expChunkSize : "160KiB" , //range defined in fetchChunkSizeKiB - min 160 KiB
28
28
},
29
29
{
30
30
name : "cacheSize set to KiB also sets the chunk size to range floor" ,
31
- cacheSize : "1 " ,
31
+ cacheSize : "1GiB " ,
32
32
expChunkSize : "160KiB" , //range defined in fetchChunkSizeKiB - min 160 KiB
33
33
},
34
+ {
35
+ name : "chunk size with GiB string parses correctly" ,
36
+ cacheSize : "375GiB" ,
37
+ expChunkSize : "384KiB" ,
38
+ },
34
39
{
35
40
name : "invalid cacheSize" ,
36
41
cacheSize : "fdfsdKi" ,
You can’t perform that action at this time.
0 commit comments