diff --git a/pkg/controller/endpointslice/endpointslice_controller.go b/pkg/controller/endpointslice/endpointslice_controller.go index 9ad83851063..00f20d0e0be 100644 --- a/pkg/controller/endpointslice/endpointslice_controller.go +++ b/pkg/controller/endpointslice/endpointslice_controller.go @@ -251,6 +251,8 @@ func (c *Controller) syncService(key string) error { if err != nil { if apierrors.IsNotFound(err) { c.triggerTimeTracker.DeleteService(namespace, name) + // The service has been deleted, return nil so that it won't be retried. + return nil } return err } diff --git a/pkg/controller/endpointslice/endpointslice_controller_test.go b/pkg/controller/endpointslice/endpointslice_controller_test.go index e8047b625a3..7db25d847bd 100644 --- a/pkg/controller/endpointslice/endpointslice_controller_test.go +++ b/pkg/controller/endpointslice/endpointslice_controller_test.go @@ -140,9 +140,8 @@ func TestSyncServiceMissing(t *testing.T) { err := esController.syncService(fmt.Sprintf("%s/%s", namespace, missingServiceName)) - // Since the service doesn't exist, we should get a not found error - assert.NotNil(t, err, "Expected no error syncing service") - assert.Equal(t, err.Error(), "service \"notthere\" not found") + // nil should be returned when the service doesn't exist + assert.Nil(t, err, "Expected no error syncing service") // That should mean no client actions were performed assert.Len(t, client.Actions(), 0)