Skip to content

Commit d3f927d

Browse files
pasanwclaude
andcommitted
fix: support WatchListClient in test ListerWatcher wrappers
k8s.io/client-go v0.35.0 defaults the WatchListClient feature gate to true, causing reflectors to require bookmark events. The fake clientset handles this via IsWatchListSemanticsUnSupported(), but our custom nodeListWatch and typhaListWatch wrappers in test/utils.go did not implement this interface, causing informers to hang on HasSynced(). Add IsWatchListSemanticsUnSupported() to both wrappers so the reflector falls back to the traditional list+watch flow. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ba04c98 commit d3f927d

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

test/utils.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,15 @@ func (n nodeListWatch) Watch(options metav1.ListOptions) (watch.Interface, error
165165
return n.cs.CoreV1().Nodes().Watch(context.Background(), options)
166166
}
167167

168-
// Mock a cache.ListWatcher for nodes to use in the test as there is no other suitable
169-
// mock available in the fake packages.
168+
// IsWatchListSemanticsUnSupported signals to the reflector that this ListerWatcher
169+
// does not support watch-list semantics. Without this, the reflector in client-go
170+
// v0.35.0+ hangs waiting for bookmark events that the fake clientset doesn't send.
171+
func (n nodeListWatch) IsWatchListSemanticsUnSupported() bool {
172+
return true
173+
}
174+
175+
// Mock a cache.ListWatcher for typha deployments to use in the test as there is no
176+
// other suitable mock available in the fake packages.
170177
// Ref: https://github.com/kubernetes/client-go/issues/352#issuecomment-614740790
171178
type typhaListWatch struct {
172179
cs kubernetes.Interface
@@ -184,6 +191,12 @@ func (t typhaListWatch) Watch(options metav1.ListOptions) (watch.Interface, erro
184191
return t.cs.AppsV1().Deployments("calico-system").Watch(context.Background(), options)
185192
}
186193

194+
// IsWatchListSemanticsUnSupported signals to the reflector that this ListerWatcher
195+
// does not support watch-list semantics.
196+
func (t typhaListWatch) IsWatchListSemanticsUnSupported() bool {
197+
return true
198+
}
199+
187200
func CreateNode(c kubernetes.Interface, name string, labels map[string]string, annotations map[string]string) *corev1.Node {
188201
node := &corev1.Node{
189202
TypeMeta: metav1.TypeMeta{Kind: "Node", APIVersion: "v1"},

0 commit comments

Comments
 (0)