Skip to content

Commit 1797aa3

Browse files
authored
Merge pull request #2007 from Sneha-at/update-master
Fix units for cache size while calculating chunk size for LVM
2 parents 61b05dd + e3459b4 commit 1797aa3

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ func setupCaching(devicePath string, req *csi.NodeStageVolumeRequest, nodeId str
215215
req.GetPublishContext()[common.ContextDataCacheMode],
216216
volumeGroupName + "/" + mainLvName,
217217
"--chunksize",
218-
chunkSize, // default unit is KiB
218+
chunkSize,
219219
"--force",
220220
"-y",
221221
}
@@ -569,7 +569,7 @@ func isCachingSetup(mainLvName string) (error, bool) {
569569
func fetchChunkSizeKiB(cacheSize string) (string, error) {
570570
var chunkSize float64
571571

572-
cacheSizeInt, err := common.ConvertGiStringToInt64(cacheSize)
572+
cacheSizeInt, err := strconv.ParseInt(cacheSize, 10, 64)
573573
if err != nil {
574574
return "0", err
575575
}

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

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

+1-1
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)