Skip to content

Commit daa3ff5

Browse files
committed
Disabling data cache watcher by default if node details are not available.
Conditionally enable data cache on test node pools to fix e2e tests
1 parent f22f043 commit daa3ff5

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,13 @@ func handle() {
228228
if err != nil {
229229
klog.Fatalf("Failed to set up metadata service: %v", err.Error())
230230
}
231+
isDataCacheEnabledNodePool, err := isDataCacheEnabledNodePool(ctx, *nodeName)
232+
if err != nil {
233+
klog.Fatalf("Failed to get node info from API server: %v", err.Error())
234+
}
231235
nsArgs := driver.NodeServerArgs{
232236
EnableDataCache: *enableDataCacheFlag,
233-
DataCacheEnabledNodePool: isDataCacheEnabledNodePool(ctx, *nodeName),
237+
DataCacheEnabledNodePool: isDataCacheEnabledNodePool,
234238
}
235239
nodeServer = driver.NewNodeServer(gceDriver, mounter, deviceUtils, meta, statter, nsArgs)
236240
if *maxConcurrentFormatAndMount > 0 {
@@ -328,14 +332,17 @@ func urlFlag(target **url.URL, name string, usage string) {
328332
})
329333
}
330334

331-
func isDataCacheEnabledNodePool(ctx context.Context, nodeName string) bool {
335+
func isDataCacheEnabledNodePool(ctx context.Context, nodeName string) (bool, error) {
336+
if !*enableDataCacheFlag {
337+
return false, nil
338+
}
332339
if nodeName != common.TestNode { // disregard logic below when E2E testing.
333340
dataCacheLSSDCount, err := driver.GetDataCacheCountFromNodeLabel(ctx, nodeName)
334-
if err != nil || dataCacheLSSDCount == 0 {
335-
return false
336-
}
341+
return dataCacheLSSDCount != 0, err
342+
} else if nodeName == common.TestNode {
343+
return true, nil
337344
}
338-
return true
345+
return false, nil
339346
}
340347

341348
func fetchLssdsForRaiding(lssdCount int) ([]string, error) {

0 commit comments

Comments
 (0)