mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-08-08 15:25:26 +00:00
Replace NewIndexerInformerWatcher with NewIndexerInformerWatcherWithLogger
Signed-off-by: ChengHao Yang <17496418+tico88612@users.noreply.github.com>
This commit is contained in:
@@ -28,6 +28,7 @@ import (
|
||||
"time"
|
||||
|
||||
"k8s.io/client-go/util/retry"
|
||||
"k8s.io/klog/v2"
|
||||
|
||||
"golang.org/x/net/websocket"
|
||||
|
||||
@@ -264,7 +265,7 @@ var _ = SIGDescribe("Pods", func() {
|
||||
return podClient.Watch(ctx, options)
|
||||
},
|
||||
}
|
||||
_, informer, w, _ := watchtools.NewIndexerInformerWatcher(lw, &v1.Pod{})
|
||||
_, informer, w, _ := watchtools.NewIndexerInformerWatcherWithLogger(klog.FromContext(ctx), lw, &v1.Pod{})
|
||||
defer w.Stop()
|
||||
|
||||
ctxUntil, cancelCtx := context.WithTimeout(ctx, wait.ForeverTestTimeout)
|
||||
|
||||
@@ -40,6 +40,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
watchtools "k8s.io/client-go/tools/watch"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/kubernetes/test/e2e/framework"
|
||||
e2eservice "k8s.io/kubernetes/test/e2e/framework/service"
|
||||
imageutils "k8s.io/kubernetes/test/utils/image"
|
||||
@@ -91,7 +92,7 @@ var _ = SIGDescribe("LimitRange", func() {
|
||||
return f.ClientSet.CoreV1().LimitRanges(f.Namespace.Name).Watch(ctx, options)
|
||||
},
|
||||
}
|
||||
_, informer, w, _ := watchtools.NewIndexerInformerWatcher(lw, &v1.LimitRange{})
|
||||
_, informer, w, _ := watchtools.NewIndexerInformerWatcherWithLogger(klog.FromContext(ctx), lw, &v1.LimitRange{})
|
||||
defer w.Stop()
|
||||
|
||||
timeoutCtx, cancel := context.WithTimeout(ctx, wait.ForeverTestTimeout)
|
||||
|
||||
@@ -35,6 +35,7 @@ import (
|
||||
watchtools "k8s.io/client-go/tools/watch"
|
||||
kubeapiservertesting "k8s.io/kubernetes/cmd/kube-apiserver/app/testing"
|
||||
"k8s.io/kubernetes/test/integration/framework"
|
||||
"k8s.io/kubernetes/test/utils/ktesting"
|
||||
)
|
||||
|
||||
func noopNormalization(output []string) []string {
|
||||
@@ -66,6 +67,8 @@ func TestWatchRestartsIfTimeoutNotReached(t *testing.T) {
|
||||
// Has to be longer than 5 seconds
|
||||
timeout := 30 * time.Second
|
||||
|
||||
logger, _ := ktesting.NewTestContext(t)
|
||||
|
||||
server := kubeapiservertesting.StartTestServerOrDie(t, nil, []string{"--min-request-timeout=7"}, framework.SharedEtcd())
|
||||
defer server.TearDownFn()
|
||||
|
||||
@@ -199,7 +202,7 @@ func TestWatchRestartsIfTimeoutNotReached(t *testing.T) {
|
||||
// since the watcher is driven by an informer it is crucial to start producing only after the informer has synced
|
||||
// otherwise we might not get all expected events since the informer LIST (or watchelist) and only then WATCHES
|
||||
// all events received during the initial LIST (or watchlist) will be seen as a single event (to most recent version of an obj)
|
||||
_, informer, w, done := watchtools.NewIndexerInformerWatcher(lw, &corev1.Secret{})
|
||||
_, informer, w, done := watchtools.NewIndexerInformerWatcherWithLogger(logger, lw, &corev1.Secret{})
|
||||
cache.WaitForCacheSync(context.TODO().Done(), informer.HasSynced)
|
||||
return w, nil, func() { <-done }
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user