Skip to content

Commit 090432a

Browse files
committed
Only run data cache watcher if a data cache nodepool exist & adding
check for VG cleanup
1 parent 8ff8d2a commit 090432a

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

cmd/gce-pd-csi-driver/main.go

+10-6
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,12 @@ func handle() {
259259
if nodeName == nil || *nodeName == "" {
260260
klog.Errorf("Data Cache enabled, but --node-name not passed")
261261
}
262-
if err := setupDataCache(ctx, *nodeName, nodeServer.MetadataService.GetName()); err != nil {
263-
klog.Errorf("DataCache setup failed: %v", err)
262+
if nsArgs.DataCacheEnabledNodePool {
263+
if err := setupDataCache(ctx, *nodeName, nodeServer.MetadataService.GetName()); err != nil {
264+
klog.Errorf("Data Cache setup failed: %v", err)
265+
}
266+
go driver.StartWatcher(*nodeName)
264267
}
265-
go driver.StartWatcher(*nodeName)
266268
}
267269
}
268270

@@ -346,9 +348,11 @@ func urlFlag(target **url.URL, name string, usage string) {
346348
}
347349

348350
func isDataCacheEnabledNodePool(ctx context.Context, nodeName string) bool {
349-
dataCacheLSSDCount, err := driver.GetDataCacheCountFromNodeLabel(ctx, nodeName)
350-
if err != nil || dataCacheLSSDCount == 0 {
351-
return false
351+
if nodeName != common.TestNode { // disregard logic below when E2E testing.
352+
dataCacheLSSDCount, err := driver.GetDataCacheCountFromNodeLabel(ctx, nodeName)
353+
if err != nil || dataCacheLSSDCount == 0 {
354+
return false
355+
}
352356
}
353357
return true
354358
}

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

+4
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,10 @@ func createVg(volumeGroupName string, raidedLocalSsds string) error {
453453
}
454454

455455
func reduceVolumeGroup(volumeGroupName string, force bool) {
456+
if !checkVgExists(volumeGroupName) {
457+
klog.V(2).Infof("Volume group %v not found, no further action needed", volumeGroupName)
458+
return
459+
}
456460
args := []string{
457461
"--removemissing",
458462
volumeGroupName,

0 commit comments

Comments
 (0)