Skip to content

Commit 55248d7

Browse files
Merge pull request #135005 from p0lyn0mial/upstream-watchlist-unsupported-wl-tracker-wrapp
apiserver/pkg/admission/plugin/policy/test: wrap trackers with ToListWatcherWithWatchListSemantics Kubernetes-commit: 3c2e64ec789935bdd8c0d93b14e84826d4aee220
2 parents c3bf0cb + 45684d9 commit 55248d7

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

pkg/admission/plugin/policy/generic/policy_test_context.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,27 +159,27 @@ func NewPolicyTestContext[P, B runtime.Object, E Evaluator](
159159
// Make an informer for our policies and bindings
160160

161161
policyInformer := cache.NewSharedIndexInformer(
162-
&cache.ListWatch{
162+
cache.ToListWatcherWithWatchListSemantics(&cache.ListWatch{
163163
ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
164164
return policiesAndBindingsTracker.List(fakePolicyGVR, fakePolicyGVK, "")
165165
},
166166
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
167167
return policiesAndBindingsTracker.Watch(fakePolicyGVR, "")
168168
},
169-
},
169+
}, policiesAndBindingsTracker),
170170
Pexample,
171171
30*time.Second,
172172
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
173173
)
174174
bindingInformer := cache.NewSharedIndexInformer(
175-
&cache.ListWatch{
175+
cache.ToListWatcherWithWatchListSemantics(&cache.ListWatch{
176176
ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
177177
return policiesAndBindingsTracker.List(fakeBindingGVR, fakeBindingGVK, "")
178178
},
179179
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
180180
return policiesAndBindingsTracker.Watch(fakeBindingGVR, "")
181181
},
182-
},
182+
}, policiesAndBindingsTracker),
183183
Bexample,
184184
30*time.Second,
185185
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},

pkg/admission/plugin/policy/internal/generic/controller_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ import (
3838
"k8s.io/apimachinery/pkg/runtime/serializer"
3939
"k8s.io/apimachinery/pkg/util/wait"
4040
"k8s.io/apimachinery/pkg/watch"
41-
4241
"k8s.io/apiserver/pkg/admission/plugin/policy/internal/generic"
4342

4443
clienttesting "k8s.io/client-go/testing"
@@ -113,14 +112,14 @@ func setupTest(ctx context.Context, customReconciler func(string, string, runtim
113112

114113
// Set up fake informers that return instances of mock Policy definitoins
115114
// and mock policy bindings
116-
informer = &testInformer{SharedIndexInformer: cache.NewSharedIndexInformer(&cache.ListWatch{
115+
informer = &testInformer{SharedIndexInformer: cache.NewSharedIndexInformer(cache.ToListWatcherWithWatchListSemantics(&cache.ListWatch{
117116
ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
118117
return tracker.List(fakeGVR, fakeGVK, "")
119118
},
120119
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
121120
return tracker.Watch(fakeGVR, "")
122121
},
123-
}, &unstructured.Unstructured{}, 30*time.Second, nil)}
122+
}, tracker), &unstructured.Unstructured{}, 30*time.Second, nil)}
124123

125124
reconciler := func(namespace, name string, newObj *unstructured.Unstructured) error {
126125
var err error

0 commit comments

Comments
 (0)