Skip to content

Commit a273638

Browse files
committed
Fix units for cache size
1 parent 9c35e66 commit a273638

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

pkg/gce-pd-csi-driver/cache.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ func setupCaching(devicePath string, req *csi.NodeStageVolumeRequest, nodeId str
210210
req.GetPublishContext()[common.ContextDataCacheMode],
211211
volumeGroupName + "/" + mainLvName,
212212
"--chunksize",
213-
chunkSize, // default unit is KiB
213+
chunkSize,
214214
"--force",
215215
"-y",
216216
}
@@ -563,7 +563,7 @@ func isCachingSetup(mainLvName string) (error, bool) {
563563
func fetchChunkSizeKiB(cacheSize string) (string, error) {
564564
var chunkSize float64
565565

566-
cacheSizeInt, err := common.ConvertGiStringToInt64(cacheSize)
566+
cacheSizeInt, err := strconv.ParseInt(cacheSize, 10, 64)
567567
if err != nil {
568568
return "0", err
569569
}

pkg/gce-pd-csi-driver/cache_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@ func TestFetchChunkSizeKiB(t *testing.T) {
1313
}{
1414
{
1515
name: "chunk size is in the allowed range",
16-
cacheSize: "500Gi",
16+
cacheSize: "500",
1717
expChunkSize: "512KiB", //range defined in fetchChunkSizeKiB
1818
},
1919
{
2020
name: "chunk size is set to the range ceil",
21-
cacheSize: "30000000Gi",
21+
cacheSize: "30000000",
2222
expChunkSize: "1048576KiB", //range defined in fetchChunkSizeKiB - max 1GiB
2323
},
2424
{
2525
name: "chunk size is set to the allowed range floor",
26-
cacheSize: "10Gi",
26+
cacheSize: "100",
2727
expChunkSize: "160KiB", //range defined in fetchChunkSizeKiB - min 160 KiB
2828
},
2929
{
3030
name: "cacheSize set to KiB also sets the chunk size to range floor",
31-
cacheSize: "100Ki",
31+
cacheSize: "1",
3232
expChunkSize: "160KiB", //range defined in fetchChunkSizeKiB - min 160 KiB
3333
},
3434
{

0 commit comments

Comments
 (0)