Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused cleanup code in endpointslice-controller #5148

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 1 addition & 19 deletions pkg/controllers/mcs/endpointslice_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/labels"
utilerrors "k8s.io/apimachinery/pkg/util/errors"
"k8s.io/client-go/tools/record"
"k8s.io/klog/v2"
controllerruntime "sigs.k8s.io/controller-runtime"
Expand Down Expand Up @@ -57,24 +56,7 @@ func (c *EndpointSliceController) Reconcile(ctx context.Context, req controllerr
work := &workv1alpha1.Work{}
if err := c.Client.Get(ctx, req.NamespacedName, work); err != nil {
if apierrors.IsNotFound(err) {
// Clean up derived EndpointSlices after work has been removed.
endpointSlices := &discoveryv1.EndpointSliceList{}
if err = c.List(context.TODO(), endpointSlices, client.HasLabels{workv1alpha2.WorkPermanentIDLabel}); err != nil {
return controllerruntime.Result{}, err
}

var errs []error
for i, es := range endpointSlices.Items {
if es.Annotations[workv1alpha2.WorkNamespaceAnnotation] == req.Namespace &&
es.Annotations[workv1alpha2.WorkNameAnnotation] == req.Name {
if err := c.Delete(context.TODO(), &endpointSlices.Items[i]); err != nil && !apierrors.IsNotFound(err) {
klog.Errorf("Failed to delete endpointslice(%s/%s) after the work(%s/%s) has been removed, err: %v",
es.Namespace, es.Name, req.Namespace, req.Name, err)
errs = append(errs, err)
}
}
}
return controllerruntime.Result{}, utilerrors.NewAggregate(errs)
return controllerruntime.Result{}, nil
}
return controllerruntime.Result{}, err
}
Expand Down