Skip to content

Commit

Permalink
Fix EndpointSliceController service deletion processing
Browse files Browse the repository at this point in the history
syncService shouldn't return error if the service doesn't exist which
means it's triggered by service deletion, otherwise the service would be
enqueued repeatedly even its cleanup has been executed successfully.

This patch makes syncService return nil if the error is NotFound when
getting the service, like the other controllers do.
  • Loading branch information
tnqn committed Sep 22, 2019
1 parent 60044a8 commit db6bbf2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 2 additions & 0 deletions pkg/controller/endpointslice/endpointslice_controller.go
Expand Up @@ -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
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/controller/endpointslice/endpointslice_controller_test.go
Expand Up @@ -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)
Expand Down

0 comments on commit db6bbf2

Please sign in to comment.