Change:
<!-- Please use this template while reporting a bug and provide as much info as possible. Not doing so may result in your bug not being addressed in a timely manner. Thanks! If the matter is security related, please disclose it privately via --What happened: Mistake use obj as prevObj prevEndpointSlice := obj.(discovery.EndpointSlice) What you expected to happen: prevEndpointSlice := prevObj.(discovery.EndpointSlice) How to reproduce it (as minimally and precisely as possible): Anything else we need to know?: Environment: Kubernetes version (use ): Cloud provider or hardware configuration: OS (e.g: ): Kernel (e.g. ): Install tools: Network plugin and version (if this is a network-related bug): Others: cc
/sig network
/triage unresolved Comment when the issue is assessed and confirmed. I am a bot run by vllry. ‍
/remove-triage unresolved PR for fixing it Thanks

Discussion:
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/intstr:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/rand:go_default_library", <ins> "//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library", </ins> "//staging/src/k8s.io/client-go/informers:go_default_library", "//staging/src/k8s.io/client-go/kubernetes/fake:go_default_library", "//staging/src/k8s.io/client-go/listers/core/v1:go_default_library",

// endpointSliceTracker or the managed-by value of the EndpointSlice has changed // from or to this controller. func (c *Controller) onEndpointSliceUpdate(prevObj, obj interface{}) { <del> prevEndpointSlice := obj.(*discovery.EndpointSlice) </del> <ins> prevEndpointSlice := prevObj.(*discovery.EndpointSlice) </ins> endpointSlice := obj.(*discovery.EndpointSlice) if endpointSlice == nil || prevEndpointSlice == nil { utilruntime.HandleError(fmt.Errorf("Invalid EndpointSlice provided to onEndpointSliceUpdate()"))

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/intstr" <ins> "k8s.io/apimachinery/pkg/util/wait" </ins> "k8s.io/client-go/informers" "k8s.io/client-go/kubernetes/fake" k8stesting "k8s.io/client-go/testing"

cmc.Check(t) } <ins> func TestOnEndpointSliceUpdate(t *testing.T) { _, esController := newController([]string{"node-1"}, time.Duration(0)) ns := metav1.NamespaceDefault serviceName := "testing-1" epSlice1 := &discovery.EndpointSlice{ ObjectMeta: metav1.ObjectMeta{ Name:      "matching-1", Namespace: ns, Labels: map[string]string{ discovery.LabelServiceName: serviceName, discovery.LabelManagedBy:   controllerName, }, }, AddressType: discovery.AddressTypeIPv4, } epSlice2 := epSlice1.DeepCopy() epSlice2.Labels[discovery.LabelManagedBy] = "something else" assert.Equal(t, 0, esController.queue.Len()) esController.onEndpointSliceUpdate(epSlice1, epSlice2) err := wait.PollImmediate(100*time.Millisecond, 3*time.Second, func() (bool, error) { if esController.queue.Len() > 0 { return true, nil } return false, nil }) if err != nil { t.Fatalf("unexpected error waiting for add to queue") } assert.Equal(t, 1, esController.queue.Len()) } </ins> // Ensure SyncService handles a variety of protocols and IPs appropriately. func TestSyncServiceFull(t *testing.T) { client, esController := newController([]string{"node-1"}, time.Duration(0))