Skip to content

Commit 60d1056

Browse files
harivallkishorj
authored andcommitted
clean up code
1 parent 063ffd0 commit 60d1056

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

controllers/elbv2/eventhandlers/endpointslices.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ package eventhandlers
22

33
import (
44
"context"
5-
"errors"
65

76
"github.com/go-logr/logr"
7+
"github.com/pkg/errors"
88
discv1 "k8s.io/api/discovery/v1beta1"
99
"k8s.io/apimachinery/pkg/api/equality"
1010
"k8s.io/apimachinery/pkg/types"
@@ -18,6 +18,8 @@ import (
1818
"sigs.k8s.io/controller-runtime/pkg/reconcile"
1919
)
2020

21+
const svcNameLabel = "kubernetes.io/service-name"
22+
2123
// NewEnqueueRequestsForEndpointSlicesEvent constructs new enqueueRequestsForEndpointSlicesEvent.
2224
func NewEnqueueRequestsForEndpointSlicesEvent(k8sClient client.Client, logger logr.Logger) handler.EventHandler {
2325
return &enqueueRequestsForEndpointSlicesEvent{
@@ -44,7 +46,7 @@ func (h *enqueueRequestsForEndpointSlicesEvent) Create(e event.CreateEvent, queu
4446
func (h *enqueueRequestsForEndpointSlicesEvent) Update(e event.UpdateEvent, queue workqueue.RateLimitingInterface) {
4547
epOld := e.ObjectOld.(*discv1.EndpointSlice)
4648
epNew := e.ObjectNew.(*discv1.EndpointSlice)
47-
h.logger.Info("Update event for EndpointSlices", "name", epNew.Name)
49+
h.logger.V(1).Info("Update event for EndpointSlices", "name", epNew.Name)
4850
if !equality.Semantic.DeepEqual(epOld.Ports, epNew.Ports) || !equality.Semantic.DeepEqual(epOld.Endpoints, epNew.Endpoints) {
4951
h.logger.V(1).Info("Enqueue EndpointSlice", "name", epNew.Name)
5052
h.enqueueImpactedTargetGroupBindings(queue, epNew)
@@ -65,10 +67,9 @@ func (h *enqueueRequestsForEndpointSlicesEvent) Generic(event.GenericEvent, work
6567

6668
func (h *enqueueRequestsForEndpointSlicesEvent) enqueueImpactedTargetGroupBindings(queue workqueue.RateLimitingInterface, epSlice *discv1.EndpointSlice) {
6769
tgbList := &elbv2api.TargetGroupBindingList{}
68-
const svcNameLabel = "kubernetes.io/service-name"
6970
svcName, present := epSlice.Labels[svcNameLabel]
7071
if !present {
71-
err := errors.New("EndpointSlice does not have a" + svcNameLabel + "label")
72+
err := errors.Errorf("EndpointSlice does not have a %v label", svcNameLabel)
7273
h.logger.Error(err, "unable to find service name for endpointslice")
7374
return
7475
}

controllers/elbv2/targetgroupbinding_controller.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ func (r *targetGroupBindingReconciler) Reconcile(ctx context.Context, req ctrl.R
9696

9797
func (r *targetGroupBindingReconciler) reconcile(ctx context.Context, req ctrl.Request) error {
9898
tgb := &elbv2api.TargetGroupBinding{}
99-
r.logger.V(1).Info("reconcile request Get", "name", req.Name, "tgb name", tgb.ObjectMeta.Name)
10099
if err := r.k8sClient.Get(ctx, req.NamespacedName, tgb); err != nil {
101100
return client.IgnoreNotFound(err)
102101
}

pkg/backend/endpoint_resolver.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import (
1616
"sigs.k8s.io/controller-runtime/pkg/client"
1717
)
1818

19+
const svcNameLabel = "kubernetes.io/service-name"
20+
1921
var ErrNotFound = errors.New("backend not found")
2022

2123
// TODO: for pod endpoints, we currently rely on endpoints events, we might change to use pod events directly in the future.
@@ -139,7 +141,6 @@ func (r *defaultEndpointResolver) ResolvePodEndpointsFromSlices(ctx context.Cont
139141
return nil, false, err
140142
}
141143

142-
const svcNameLabel = "kubernetes.io/service-name"
143144
epSlicesList := &discv1.EndpointSliceList{}
144145
if err := r.k8sClient.List(ctx, epSlicesList,
145146
client.InNamespace(svcKey.Namespace),

pkg/config/controller_config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ type ControllerConfig struct {
6868
// the SSL Policy annotation.
6969
DefaultSSLPolicy string
7070

71-
// Whether to use endpointslices resources(true) or Endpoints resources(false) in endpoint and TGB resolution.
71+
// Enable EndpointSlices for IP targets instead of Endpoints
7272
EnableEndpointSlices bool
7373

7474
// Max concurrent reconcile loops for Service objects

0 commit comments

Comments
 (0)