From 3195e36899a554071d02c146344153ea77658426 Mon Sep 17 00:00:00 2001 From: kkkkun Date: Wed, 24 May 2023 21:09:53 +0800 Subject: [PATCH] Should get ENABLE_CLIENT_GO_WATCH_LIST_ALPHA when new reflector Signed-off-by: kkkkun Kubernetes-commit: 2eed9b4143a9009b3327003ae50dbbebb44d2841 --- tools/cache/controller.go | 4 ---- tools/cache/reflector.go | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/cache/controller.go b/tools/cache/controller.go index f437f286..8a1104bd 100644 --- a/tools/cache/controller.go +++ b/tools/cache/controller.go @@ -18,7 +18,6 @@ package cache import ( "errors" - "os" "sync" "time" @@ -148,9 +147,6 @@ func (c *controller) Run(stopCh <-chan struct{}) { if c.config.WatchErrorHandler != nil { r.watchErrorHandler = c.config.WatchErrorHandler } - if s := os.Getenv("ENABLE_CLIENT_GO_WATCH_LIST_ALPHA"); len(s) > 0 { - r.UseWatchList = true - } c.reflectorMutex.Lock() c.reflector = r diff --git a/tools/cache/reflector.go b/tools/cache/reflector.go index 2b335c10..400d4015 100644 --- a/tools/cache/reflector.go +++ b/tools/cache/reflector.go @@ -22,6 +22,7 @@ import ( "fmt" "io" "math/rand" + "os" "reflect" "strings" "sync" @@ -239,6 +240,10 @@ func NewReflectorWithOptions(lw ListerWatcher, expectedType interface{}, store S r.expectedGVK = getExpectedGVKFromObject(expectedType) } + if s := os.Getenv("ENABLE_CLIENT_GO_WATCH_LIST_ALPHA"); len(s) > 0 { + r.UseWatchList = true + } + return r }