Skip to content

Commit 17240d0

Browse files
Sneha-atk8s-infra-cherrypick-robot
authored andcommitted
Fix units for cache size
1 parent 71d159a commit 17240d0

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
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
{

test/remote/client-wrappers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const (
5656
// Keys in the volume context.
5757
contextForceAttach = "force-attach"
5858

59-
defaultLocalSsdCacheSize = "200Gi"
59+
defaultLocalSsdCacheSize = "200"
6060
defaultDataCacheMode = common.DataCacheModeWriteThrough
6161
)
6262

0 commit comments

Comments
 (0)