Skip to content

Commit f86f20d

Browse files
halimsamcemakd
authored andcommitted
Only run data cache watcher if a data cache nodepool exist & adding
check for VG cleanup
1 parent 5233508 commit f86f20d

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

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

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -236,14 +236,16 @@ func handle() {
236236
if *maxConcurrentFormatAndMount > 0 {
237237
nodeServer = nodeServer.WithSerializedFormatAndMount(*formatAndMountTimeout, *maxConcurrentFormatAndMount)
238238
}
239-
}
240-
241-
if *enableDataCacheFlag {
242-
if nodeName == nil || *nodeName == "" {
243-
klog.Errorf("Data Cache enabled, but --node-name not passed")
244-
}
245-
if err := setupDataCache(ctx, *nodeName); err != nil {
246-
klog.Errorf("Data Cache setup failed: %v", err)
239+
if *enableDataCacheFlag {
240+
if nodeName == nil || *nodeName == "" {
241+
klog.Errorf("Data Cache enabled, but --node-name not passed")
242+
}
243+
if nsArgs.DataCacheEnabledNodePool {
244+
if err := setupDataCache(ctx, *nodeName, nodeServer.MetadataService.GetName()); err != nil {
245+
klog.Errorf("Data Cache setup failed: %v", err)
246+
}
247+
go driver.StartWatcher(*nodeName)
248+
}
247249
}
248250
}
249251

@@ -327,9 +329,11 @@ func urlFlag(target **url.URL, name string, usage string) {
327329
}
328330

329331
func isDataCacheEnabledNodePool(ctx context.Context, nodeName string) bool {
330-
dataCacheLSSDCount, err := driver.GetDataCacheCountFromNodeLabel(ctx, nodeName)
331-
if err != nil || dataCacheLSSDCount == 0 {
332-
return false
332+
if nodeName != common.TestNode { // disregard logic below when E2E testing.
333+
dataCacheLSSDCount, err := driver.GetDataCacheCountFromNodeLabel(ctx, nodeName)
334+
if err != nil || dataCacheLSSDCount == 0 {
335+
return false
336+
}
333337
}
334338
return true
335339
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,10 @@ func createVg(volumeGroupName string, raidedLocalSsds string) error {
452452
}
453453

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

0 commit comments

Comments
 (0)