Repository: kubernetes
Issue: kubernetes 1.32: Informer with WatchClient fails to send events with Fakeclient
Labels: kind/bug,needs-sig,needs-triage

### What happened?

I tried to start an informer with WatchClient enabled in client go and i see this error

```
W1220 19:44:49.417766   26071 reflector.go:1044] k8s.io/client-go@v1.32/tools/cache/reflector.go:243: awaiting required bookmark event for initial events stream, no events received for 10.000196792s

```

and the above error keeps coming every 10 seconds.

The informer factory is stuck at this line

`xInformerFactory.WaitForCacheSync(ctx.Done())`





### What did you expect to happen?

Watclist feature to work and Events to propagate when a resource is created.

### How can we reproduce it (as minimally and precisely as possible)?

```
package main

import (
	"context"
	"flag"
	"fmt"
	"os"
    "time"

	corev1 "k8s.io/api/core/v1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/runtime"
	utilruntime "k8s.io/apimachinery/pkg/util/runtime"
	"k8s.io/client-go/informers"
	"k8s.io/client-go/kubernetes/fake"
	"k8s.io/client-go/tools/cache"
	"k8s.io/klog/v2"
)

func init() {
	scheme := runtime.NewScheme()
	utilruntime.Must(corev1.AddToScheme(scheme))

}

func main() {
	os.Setenv("KUBE_FEATURE_WatchListClient", "true")
	client := fake.NewSimpleClientset()

	defer klog.Flush()
	flagSet := flag.NewFlagSet("test", flag.ExitOnError)
	klog.InitFlags(flagSet)
	_ = flagSet.Parse([]string{"--v", "6"})

	// Create an informer factory for the fake client
	informerFactory := informers.NewSharedInformerFactory(client, 0)

	// Get the Pod informer
	podInformer := informerFactory.Core().V1().Pods().Informer()

	// Add an event handler to the informer
	podInformer.AddEventHandler(&cache.ResourceEventHandlerFuncs{
		AddFunc: func(obj interface{}) {
			pod := obj.(*corev1.Pod)
			fmt.Printf("Pod added: %s/%s\n", pod.Namespace, pod.Name)
		},
		UpdateFunc: func(oldObj, newObj interface{}) {
			newPod := newObj.(*corev1.Pod)
			fmt.Printf("Pod updated: %s/%s\n", newPod.Namespace, newPod.Name)
		},
		DeleteFunc: func(obj interface{}) {
			pod := obj.(*corev1.Pod)
			fmt.Printf("Pod deleted: %s/%s\n", pod.Namespace, pod.Name)
		},
	})

	// Start the informer
	stopCh := make(chan struct{})
	defer close(stopCh)
	informerFactory.Start(stopCh)

	// Wait for cache sync
	if !cache.WaitForCacheSync(stopCh, podInformer.HasSynced) {
		fmt.Println("Failed to sync cache")
		return
	}
	// Use the client to create, update, or fetch resources
	pod := &corev1.Pod{
		ObjectMeta: metav1.ObjectMeta{
			Name:      "example-pod",
			Namespace: "default",
		},
		Spec: corev1.PodSpec{
			Containers: []corev1.Container{
				{
					Name:  "example-container",
					Image: "nginx",
				},
			},
		},
	}

	// Create a Pod
	_, err := client.CoreV1().Pods("default").Create(context.TODO(), pod, metav1.CreateOptions{})
	if err != nil {
		panic(err)
	}

	
	time.Sleep(time.Second * 5) 
	stopCh <- struct{}{}
}
```

go.mod file:

```
module myworks/watchlist-test

go 1.23.0

require (
	k8s.io/api v0.32.0
	k8s.io/apimachinery v0.32.0
	k8s.io/client-go v0.32.0
	k8s.io/klog/v2 v2.130.1
)

require (
	github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
	github.com/emicklei/go-restful/v3 v3.11.0 // indirect
	github.com/fxamacker/cbor/v2 v2.7.0 // indirect
	github.com/go-logr/logr v1.4.2 // indirect
	github.com/go-openapi/jsonpointer v0.21.0 // indirect
	github.com/go-openapi/jsonreference v0.20.2 // indirect
	github.com/go-openapi/swag v0.23.0 // indirect
	github.com/gogo/protobuf v1.3.2 // indirect
	github.com/golang/protobuf v1.5.4 // indirect
	github.com/google/gnostic-models v0.6.8 // indirect
	github.com/google/go-cmp v0.6.0 // indirect
	github.com/google/gofuzz v1.2.0 // indirect
	github.com/google/uuid v1.6.0 // indirect
	github.com/josharian/intern v1.0.0 // indirect
	github.com/json-iterator/go v1.1.12 // indirect
	github.com/mailru/easyjson v0.7.7 // indirect
	github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
	github.com/modern-go/reflect2 v1.0.2 // indirect
	github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
	github.com/pkg/errors v0.9.1 // indirect
	github.com/x448/float16 v0.8.4 // indirect
	golang.org/x/net v0.30.0 // indirect
	golang.org/x/oauth2 v0.23.0 // indirect
	golang.org/x/sys v0.26.0 // indirect
	golang.org/x/term v0.25.0 // indirect
	golang.org/x/text v0.19.0 // indirect
	golang.org/x/time v0.7.0 // indirect
	google.golang.org/protobuf v1.35.1 // indirect
	gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
	gopkg.in/inf.v0 v0.9.1 // indirect
	gopkg.in/yaml.v3 v3.0.1 // indirect
	k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect
	k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect
	sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect
	sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect
	sigs.k8s.io/yaml v1.4.0 // indirect
)
```



Error logs:
```
go run main.go
I1223 14:40:04.018354   35133 envvar.go:172] "Feature gate default state" feature="ClientsPreferCBOR" enabled=false
I1223 14:40:04.018890   35133 envvar.go:172] "Feature gate default state" feature="InformerResourceVersion" enabled=false
I1223 14:40:04.018897   35133 envvar.go:169] "Feature gate updated state" feature="WatchListClient" enabled=true
I1223 14:40:04.018901   35133 envvar.go:172] "Feature gate default state" feature="ClientsAllowCBOR" enabled=false
I1223 14:40:04.018930   35133 reflector.go:313] Starting reflector *v1.Pod (0s) from pkg/mod/k8s.io/client-go@v0.32.0/tools/cache/reflector.go:251
I1223 14:40:04.018968   35133 reflector.go:349] Listing and watching *v1.Pod from pkg/mod/k8s.io/client-go@v0.32.0/tools/cache/reflector.go:251
W1223 14:40:14.020097   35133 reflector.go:1052] pkg/mod/k8s.io/client-go@v0.32.0/tools/cache/reflector.go:251: awaiting required bookmark event for initial events stream, no events received for 10.000426333s
W1223 14:40:24.019566   35133 reflector.go:1052] pkg/mod/k8s.io/client-go@v0.32.0/tools/cache/reflector.go:251: awaiting required bookmark event for initial events stream, no events received for 20.000542791s
```




### Anything else we need to know?


change the env var to false and you see things are working. 

```
os.Setenv("KUBE_FEATURE_WatchListClient", "false")
```

Logs:

```
go run main.go
I1223 14:45:47.374375   39780 envvar.go:172] "Feature gate default state" feature="ClientsAllowCBOR" enabled=false
I1223 14:45:47.374853   39780 envvar.go:172] "Feature gate default state" feature="ClientsPreferCBOR" enabled=false
I1223 14:45:47.374859   39780 envvar.go:172] "Feature gate default state" feature="InformerResourceVersion" enabled=false
I1223 14:45:47.374864   39780 envvar.go:169] "Feature gate updated state" feature="WatchListClient" enabled=false
I1223 14:45:47.374889   39780 reflector.go:313] Starting reflector *v1.Pod (0s) from pkg/mod/k8s.io/client-go@v0.32.0/tools/cache/reflector.go:251
I1223 14:45:47.374927   39780 reflector.go:349] Listing and watching *v1.Pod from pkg/mod/k8s.io/client-go@v0.32.0/tools/cache/reflector.go:251
I1223 14:45:47.375349   39780 reflector.go:376] Caches populated for *v1.Pod from pkg/mod/k8s.io/client-go@v0.32.0/tools/cache/reflector.go:251
Pod added: default/example-pod
```

### Kubernetes version

Client Version: v1.32.0

### Cloud provider

Local

### OS version

MacOS
Darwin Kernel Version 23.6.0

### Install tools

golang 

```
go version
go version go1.23.0 darwin/arm64
```

### Container runtime (CRI) and version (if applicable)

<details>

</details>


### Related plugins (CNI, CSI, ...) and versions (if applicable)

<details>

</details>