From 26c608fd031b78ca802bb87b6dfa593b7880130f Mon Sep 17 00:00:00 2001 From: Engin Akdemir Date: Tue, 23 Sep 2025 17:32:44 +0000 Subject: [PATCH 1/2] Fix partial cache tail latency by correcting the cache chunk size calculation Undo temporary chunk size changes Fix temporary variable name change --- pkg/gce-pd-csi-driver/cache.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkg/gce-pd-csi-driver/cache.go b/pkg/gce-pd-csi-driver/cache.go index b2ccd5e70..229845dc2 100644 --- a/pkg/gce-pd-csi-driver/cache.go +++ b/pkg/gce-pd-csi-driver/cache.go @@ -576,6 +576,7 @@ func isCachingSetup(mainLvName string) (error, bool) { func fetchChunkSizeKiB(cacheSize string) (string, error) { var chunkSize float64 + cacheSize = strings.TrimSuffix(cacheSize, "GiB") cacheSizeInt, err := strconv.ParseInt(cacheSize, 10, 64) if err != nil { return "0", err @@ -691,10 +692,8 @@ func addRaidedLSSDToVg(vgName, lssdPath string) error { func fetchPvSizeGiB() (string, error) { args := []string{ - "--select", - "-o", + "-o", "pv_name,pv_size", "--noheadings", - "pv_size", "--units=b", } // 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 From b585ad7b656f4c0b702c41fbba81ffa8157f35a8 Mon Sep 17 00:00:00 2001 From: Engin Akdemir Date: Tue, 23 Sep 2025 18:15:13 +0000 Subject: [PATCH 2/2] Add unit test to fetchChucnkSizeKiB Update existing unit test to have suffix GiB Add comment to clarify cache size is always in GiB --- pkg/gce-pd-csi-driver/cache.go | 1 + pkg/gce-pd-csi-driver/cache_test.go | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/pkg/gce-pd-csi-driver/cache.go b/pkg/gce-pd-csi-driver/cache.go index 229845dc2..d5d0ea498 100644 --- a/pkg/gce-pd-csi-driver/cache.go +++ b/pkg/gce-pd-csi-driver/cache.go @@ -573,6 +573,7 @@ func isCachingSetup(mainLvName string) (error, bool) { return nil, false } +// cacheSize is always in GiB func fetchChunkSizeKiB(cacheSize string) (string, error) { var chunkSize float64 diff --git a/pkg/gce-pd-csi-driver/cache_test.go b/pkg/gce-pd-csi-driver/cache_test.go index 340c924a1..1b219f20e 100644 --- a/pkg/gce-pd-csi-driver/cache_test.go +++ b/pkg/gce-pd-csi-driver/cache_test.go @@ -13,24 +13,29 @@ func TestFetchChunkSizeKiB(t *testing.T) { }{ { name: "chunk size is in the allowed range", - cacheSize: "500", + cacheSize: "500GiB", expChunkSize: "512KiB", //range defined in fetchChunkSizeKiB }, { name: "chunk size is set to the range ceil", - cacheSize: "30000000", + cacheSize: "30000000GiB", expChunkSize: "1048576KiB", //range defined in fetchChunkSizeKiB - max 1GiB }, { name: "chunk size is set to the allowed range floor", - cacheSize: "100", + cacheSize: "100GiB", expChunkSize: "160KiB", //range defined in fetchChunkSizeKiB - min 160 KiB }, { name: "cacheSize set to KiB also sets the chunk size to range floor", - cacheSize: "1", + cacheSize: "1GiB", expChunkSize: "160KiB", //range defined in fetchChunkSizeKiB - min 160 KiB }, + { + name: "chunk size with GiB string parses correctly", + cacheSize: "375GiB", + expChunkSize: "384KiB", + }, { name: "invalid cacheSize", cacheSize: "fdfsdKi",