Skip to content

Commit 2929634

Browse files
committed
Disabling data cache watcher by default if node details are not available.
1 parent f22f043 commit 2929634

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

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

Lines changed: 11 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,15 @@ 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
337342
}
338-
return true
343+
return false, nil
339344
}
340345

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

0 commit comments

Comments
 (0)