Skip to content

Commit

Permalink
Merge pull request #4011 from zac-nixon/znixon/controller-runtime-bump
Browse files Browse the repository at this point in the history
bump sigs.k8s.io/controller-runtime to v0.19.3
  • Loading branch information
k8s-ci-robot authored Jan 11, 2025
2 parents ba40696 + 10e5f72 commit f1435b3
Show file tree
Hide file tree
Showing 21 changed files with 233 additions and 232 deletions.
10 changes: 5 additions & 5 deletions controllers/elbv2/eventhandlers/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ type enqueueRequestsForEndpointsEvent struct {
}

// Create is called in response to an create event - e.g. Pod Creation.
func (h *enqueueRequestsForEndpointsEvent) Create(ctx context.Context, e event.CreateEvent, queue workqueue.RateLimitingInterface) {
func (h *enqueueRequestsForEndpointsEvent) Create(ctx context.Context, e event.CreateEvent, queue workqueue.TypedRateLimitingInterface[reconcile.Request]) {
epNew := e.Object.(*corev1.Endpoints)
h.enqueueImpactedTargetGroupBindings(queue, epNew)
}

// Update is called in response to an update event - e.g. Pod Updated.
func (h *enqueueRequestsForEndpointsEvent) Update(ctx context.Context, e event.UpdateEvent, queue workqueue.RateLimitingInterface) {
func (h *enqueueRequestsForEndpointsEvent) Update(ctx context.Context, e event.UpdateEvent, queue workqueue.TypedRateLimitingInterface[reconcile.Request]) {
epOld := e.ObjectOld.(*corev1.Endpoints)
epNew := e.ObjectNew.(*corev1.Endpoints)
if !equality.Semantic.DeepEqual(epOld.Subsets, epNew.Subsets) {
Expand All @@ -48,17 +48,17 @@ func (h *enqueueRequestsForEndpointsEvent) Update(ctx context.Context, e event.U
}

// Delete is called in response to a delete event - e.g. Pod Deleted.
func (h *enqueueRequestsForEndpointsEvent) Delete(ctx context.Context, e event.DeleteEvent, queue workqueue.RateLimitingInterface) {
func (h *enqueueRequestsForEndpointsEvent) Delete(ctx context.Context, e event.DeleteEvent, queue workqueue.TypedRateLimitingInterface[reconcile.Request]) {
epOld := e.Object.(*corev1.Endpoints)
h.enqueueImpactedTargetGroupBindings(queue, epOld)
}

// Generic is called in response to an event of an unknown type or a synthetic event triggered as a cron or
// external trigger request - e.g. reconcile AutoScaling, or a WebHook.
func (h *enqueueRequestsForEndpointsEvent) Generic(context.Context, event.GenericEvent, workqueue.RateLimitingInterface) {
func (h *enqueueRequestsForEndpointsEvent) Generic(context.Context, event.GenericEvent, workqueue.TypedRateLimitingInterface[reconcile.Request]) {
}

func (h *enqueueRequestsForEndpointsEvent) enqueueImpactedTargetGroupBindings(queue workqueue.RateLimitingInterface, ep *corev1.Endpoints) {
func (h *enqueueRequestsForEndpointsEvent) enqueueImpactedTargetGroupBindings(queue workqueue.TypedRateLimitingInterface[reconcile.Request], ep *corev1.Endpoints) {
tgbList := &elbv2api.TargetGroupBindingList{}
if err := h.k8sClient.List(context.Background(), tgbList,
client.InNamespace(ep.Namespace),
Expand Down
10 changes: 5 additions & 5 deletions controllers/elbv2/eventhandlers/endpoints_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package eventhandlers

import (
"context"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"testing"

"github.com/go-logr/logr"
Expand All @@ -15,7 +16,6 @@ import (
elbv2api "sigs.k8s.io/aws-load-balancer-controller/apis/elbv2/v1beta1"
mock_client "sigs.k8s.io/aws-load-balancer-controller/mocks/controller-runtime/client"
"sigs.k8s.io/aws-load-balancer-controller/pkg/testutils"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllertest"
"sigs.k8s.io/controller-runtime/pkg/log"
Expand All @@ -40,7 +40,7 @@ func Test_enqueueRequestsForEndpointsEvent_enqueueImpactedTargetGroupBindings(t
name string
fields fields
args args
wantRequests []ctrl.Request
wantRequests []reconcile.Request
}{
{
name: "service event should enqueue impacted ip TargetType TGBs",
Expand Down Expand Up @@ -91,7 +91,7 @@ func Test_enqueueRequestsForEndpointsEvent_enqueueImpactedTargetGroupBindings(t
},
},
},
wantRequests: []ctrl.Request{
wantRequests: []reconcile.Request{
{
NamespacedName: types.NamespacedName{Namespace: "awesome-ns", Name: "tgb-1"},
},
Expand Down Expand Up @@ -140,7 +140,7 @@ func Test_enqueueRequestsForEndpointsEvent_enqueueImpactedTargetGroupBindings(t
},
},
},
wantRequests: []ctrl.Request{
wantRequests: []reconcile.Request{
{
NamespacedName: types.NamespacedName{Namespace: "awesome-ns", Name: "tgb-1"},
},
Expand Down Expand Up @@ -172,7 +172,7 @@ func Test_enqueueRequestsForEndpointsEvent_enqueueImpactedTargetGroupBindings(t
k8sClient: k8sClient,
logger: logr.New(&log.NullLogSink{}),
}
queue := &controllertest.Queue{Interface: workqueue.New()}
queue := &controllertest.TypedQueue[reconcile.Request]{TypedInterface: workqueue.NewTyped[reconcile.Request]()}
h.enqueueImpactedTargetGroupBindings(queue, tt.args.eps)
gotRequests := testutils.ExtractCTRLRequestsFromQueue(queue)
assert.True(t, cmp.Equal(tt.wantRequests, gotRequests),
Expand Down
10 changes: 5 additions & 5 deletions controllers/elbv2/eventhandlers/endpointslices.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ type enqueueRequestsForEndpointSlicesEvent struct {
}

// Create is called in response to an create event - e.g. EndpointSlice Creation.
func (h *enqueueRequestsForEndpointSlicesEvent) Create(ctx context.Context, e event.CreateEvent, queue workqueue.RateLimitingInterface) {
func (h *enqueueRequestsForEndpointSlicesEvent) Create(ctx context.Context, e event.CreateEvent, queue workqueue.TypedRateLimitingInterface[reconcile.Request]) {
epNew := e.Object.(*discv1.EndpointSlice)
h.logger.V(1).Info("Create event for EndpointSlices", "name", epNew.Name)
h.enqueueImpactedTargetGroupBindings(ctx, queue, epNew)
}

// Update is called in response to an update event - e.g. EndpointSlice Updated.
func (h *enqueueRequestsForEndpointSlicesEvent) Update(ctx context.Context, e event.UpdateEvent, queue workqueue.RateLimitingInterface) {
func (h *enqueueRequestsForEndpointSlicesEvent) Update(ctx context.Context, e event.UpdateEvent, queue workqueue.TypedRateLimitingInterface[reconcile.Request]) {
epOld := e.ObjectOld.(*discv1.EndpointSlice)
epNew := e.ObjectNew.(*discv1.EndpointSlice)
h.logger.V(1).Info("Update event for EndpointSlices", "name", epNew.Name)
Expand All @@ -54,18 +54,18 @@ func (h *enqueueRequestsForEndpointSlicesEvent) Update(ctx context.Context, e ev
}

// Delete is called in response to a delete event - e.g. EndpointSlice Deleted.
func (h *enqueueRequestsForEndpointSlicesEvent) Delete(ctx context.Context, e event.DeleteEvent, queue workqueue.RateLimitingInterface) {
func (h *enqueueRequestsForEndpointSlicesEvent) Delete(ctx context.Context, e event.DeleteEvent, queue workqueue.TypedRateLimitingInterface[reconcile.Request]) {
epOld := e.Object.(*discv1.EndpointSlice)
h.logger.V(1).Info("Deletion event for EndpointSlices", "name", epOld.Name)
h.enqueueImpactedTargetGroupBindings(ctx, queue, epOld)
}

// Generic is called in response to an event of an unknown type or a synthetic event triggered as a cron or
// external trigger request - e.g. reconcile AutoScaling, or a WebHook.
func (h *enqueueRequestsForEndpointSlicesEvent) Generic(context.Context, event.GenericEvent, workqueue.RateLimitingInterface) {
func (h *enqueueRequestsForEndpointSlicesEvent) Generic(context.Context, event.GenericEvent, workqueue.TypedRateLimitingInterface[reconcile.Request]) {
}

func (h *enqueueRequestsForEndpointSlicesEvent) enqueueImpactedTargetGroupBindings(ctx context.Context, queue workqueue.RateLimitingInterface, epSlice *discv1.EndpointSlice) {
func (h *enqueueRequestsForEndpointSlicesEvent) enqueueImpactedTargetGroupBindings(ctx context.Context, queue workqueue.TypedRateLimitingInterface[reconcile.Request], epSlice *discv1.EndpointSlice) {
tgbList := &elbv2api.TargetGroupBindingList{}
svcName, present := epSlice.Labels[svcNameLabel]
if !present {
Expand Down
10 changes: 5 additions & 5 deletions controllers/elbv2/eventhandlers/endpointslices_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package eventhandlers

import (
"context"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"testing"

"github.com/go-logr/logr"
Expand All @@ -15,7 +16,6 @@ import (
elbv2api "sigs.k8s.io/aws-load-balancer-controller/apis/elbv2/v1beta1"
mock_client "sigs.k8s.io/aws-load-balancer-controller/mocks/controller-runtime/client"
"sigs.k8s.io/aws-load-balancer-controller/pkg/testutils"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllertest"
"sigs.k8s.io/controller-runtime/pkg/log"
Expand All @@ -40,7 +40,7 @@ func Test_enqueueRequestsForEndpointSlicesEvent_enqueueImpactedTargetGroupBindin
name string
fields fields
args args
wantRequests []ctrl.Request
wantRequests []reconcile.Request
}{
{
name: "service event should enqueue impacted ip TargetType TGBs",
Expand Down Expand Up @@ -92,7 +92,7 @@ func Test_enqueueRequestsForEndpointSlicesEvent_enqueueImpactedTargetGroupBindin
},
},
},
wantRequests: []ctrl.Request{
wantRequests: []reconcile.Request{
{
NamespacedName: types.NamespacedName{Namespace: "awesome-ns", Name: "tgb-1"},
},
Expand Down Expand Up @@ -142,7 +142,7 @@ func Test_enqueueRequestsForEndpointSlicesEvent_enqueueImpactedTargetGroupBindin
},
},
},
wantRequests: []ctrl.Request{
wantRequests: []reconcile.Request{
{
NamespacedName: types.NamespacedName{Namespace: "awesome-ns", Name: "tgb-1"},
},
Expand Down Expand Up @@ -174,7 +174,7 @@ func Test_enqueueRequestsForEndpointSlicesEvent_enqueueImpactedTargetGroupBindin
k8sClient: k8sClient,
logger: logr.New(&log.NullLogSink{}),
}
queue := &controllertest.Queue{Interface: workqueue.New()}
queue := &controllertest.TypedQueue[reconcile.Request]{TypedInterface: workqueue.NewTyped[reconcile.Request]()}
h.enqueueImpactedTargetGroupBindings(context.Background(), queue, tt.args.epslice)
gotRequests := testutils.ExtractCTRLRequestsFromQueue(queue)
assert.True(t, cmp.Equal(tt.wantRequests, gotRequests),
Expand Down
10 changes: 5 additions & 5 deletions controllers/elbv2/eventhandlers/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,32 @@ type enqueueRequestsForNodeEvent struct {
}

// Create is called in response to an create event - e.g. Pod Creation.
func (h *enqueueRequestsForNodeEvent) Create(ctx context.Context, e event.CreateEvent, queue workqueue.RateLimitingInterface) {
func (h *enqueueRequestsForNodeEvent) Create(ctx context.Context, e event.CreateEvent, queue workqueue.TypedRateLimitingInterface[reconcile.Request]) {
nodeNew := e.Object.(*corev1.Node)
h.enqueueImpactedTargetGroupBindings(ctx, queue, nil, nodeNew)
}

// Update is called in response to an update event - e.g. Pod Updated.
func (h *enqueueRequestsForNodeEvent) Update(ctx context.Context, e event.UpdateEvent, queue workqueue.RateLimitingInterface) {
func (h *enqueueRequestsForNodeEvent) Update(ctx context.Context, e event.UpdateEvent, queue workqueue.TypedRateLimitingInterface[reconcile.Request]) {
nodeOld := e.ObjectOld.(*corev1.Node)
nodeNew := e.ObjectNew.(*corev1.Node)
h.enqueueImpactedTargetGroupBindings(ctx, queue, nodeOld, nodeNew)
}

// Delete is called in response to a delete event - e.g. Pod Deleted.
func (h *enqueueRequestsForNodeEvent) Delete(ctx context.Context, e event.DeleteEvent, queue workqueue.RateLimitingInterface) {
func (h *enqueueRequestsForNodeEvent) Delete(ctx context.Context, e event.DeleteEvent, queue workqueue.TypedRateLimitingInterface[reconcile.Request]) {
nodeOld := e.Object.(*corev1.Node)
h.enqueueImpactedTargetGroupBindings(ctx, queue, nodeOld, nil)
}

// Generic is called in response to an event of an unknown type or a synthetic event triggered as a cron or
// external trigger request - e.g. reconcile AutoScaling, or a WebHook.
func (h *enqueueRequestsForNodeEvent) Generic(context.Context, event.GenericEvent, workqueue.RateLimitingInterface) {
func (h *enqueueRequestsForNodeEvent) Generic(context.Context, event.GenericEvent, workqueue.TypedRateLimitingInterface[reconcile.Request]) {
// nothing to do here
}

// enqueueImpactedTargetGroupBindings will enqueue all impacted TargetGroupBindings for node events.
func (h *enqueueRequestsForNodeEvent) enqueueImpactedTargetGroupBindings(ctx context.Context, queue workqueue.RateLimitingInterface, nodeOld *corev1.Node, nodeNew *corev1.Node) {
func (h *enqueueRequestsForNodeEvent) enqueueImpactedTargetGroupBindings(ctx context.Context, queue workqueue.TypedRateLimitingInterface[reconcile.Request], nodeOld *corev1.Node, nodeNew *corev1.Node) {
var nodeKey types.NamespacedName
nodeOldSuitableAsTrafficProxy := false
nodeNewSuitableAsTrafficProxy := false
Expand Down
10 changes: 5 additions & 5 deletions controllers/elbv2/eventhandlers/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ type enqueueRequestsForServiceEvent struct {
}

// Create is called in response to an create event - e.g. Pod Creation.
func (h *enqueueRequestsForServiceEvent) Create(ctx context.Context, e event.CreateEvent, queue workqueue.RateLimitingInterface) {
func (h *enqueueRequestsForServiceEvent) Create(ctx context.Context, e event.CreateEvent, queue workqueue.TypedRateLimitingInterface[reconcile.Request]) {
svcNew := e.Object.(*corev1.Service)
h.enqueueImpactedTargetGroupBindings(ctx, queue, svcNew)
}

// Update is called in response to an update event - e.g. Pod Updated.
func (h *enqueueRequestsForServiceEvent) Update(ctx context.Context, e event.UpdateEvent, queue workqueue.RateLimitingInterface) {
func (h *enqueueRequestsForServiceEvent) Update(ctx context.Context, e event.UpdateEvent, queue workqueue.TypedRateLimitingInterface[reconcile.Request]) {
svcOld := e.ObjectOld.(*corev1.Service)
svcNew := e.ObjectNew.(*corev1.Service)
if !equality.Semantic.DeepEqual(svcOld.Spec.Ports, svcNew.Spec.Ports) {
Expand All @@ -46,19 +46,19 @@ func (h *enqueueRequestsForServiceEvent) Update(ctx context.Context, e event.Upd
}

// Delete is called in response to a delete event - e.g. Pod Deleted.
func (h *enqueueRequestsForServiceEvent) Delete(ctx context.Context, e event.DeleteEvent, queue workqueue.RateLimitingInterface) {
func (h *enqueueRequestsForServiceEvent) Delete(ctx context.Context, e event.DeleteEvent, queue workqueue.TypedRateLimitingInterface[reconcile.Request]) {
svcOld := e.Object.(*corev1.Service)
h.enqueueImpactedTargetGroupBindings(ctx, queue, svcOld)
}

// Generic is called in response to an event of an unknown type or a synthetic event triggered as a cron or
// external trigger request - e.g. reconcile AutoScaling, or a WebHook.
func (h *enqueueRequestsForServiceEvent) Generic(context.Context, event.GenericEvent, workqueue.RateLimitingInterface) {
func (h *enqueueRequestsForServiceEvent) Generic(context.Context, event.GenericEvent, workqueue.TypedRateLimitingInterface[reconcile.Request]) {
// nothing to do here
}

// enqueueImpactedEndpointBindings will enqueue all impacted TargetGroupBindings for service events.
func (h *enqueueRequestsForServiceEvent) enqueueImpactedTargetGroupBindings(ctx context.Context, queue workqueue.RateLimitingInterface, svc *corev1.Service) {
func (h *enqueueRequestsForServiceEvent) enqueueImpactedTargetGroupBindings(ctx context.Context, queue workqueue.TypedRateLimitingInterface[reconcile.Request], svc *corev1.Service) {
tgbList := &elbv2api.TargetGroupBindingList{}
if err := h.k8sClient.List(context.Background(), tgbList,
client.InNamespace(svc.Namespace),
Expand Down
10 changes: 5 additions & 5 deletions controllers/elbv2/eventhandlers/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package eventhandlers

import (
"context"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"testing"

"github.com/go-logr/logr"
Expand All @@ -16,7 +17,6 @@ import (
elbv2api "sigs.k8s.io/aws-load-balancer-controller/apis/elbv2/v1beta1"
mock_client "sigs.k8s.io/aws-load-balancer-controller/mocks/controller-runtime/client"
"sigs.k8s.io/aws-load-balancer-controller/pkg/testutils"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllertest"
"sigs.k8s.io/controller-runtime/pkg/log"
Expand All @@ -41,7 +41,7 @@ func Test_enqueueRequestsForServiceEvent_enqueueImpactedTargetGroupBindings(t *t
name string
fields fields
args args
wantRequests []ctrl.Request
wantRequests []reconcile.Request
}{
{
name: "service event should enqueue impacted instance TargetType TGBs",
Expand Down Expand Up @@ -102,7 +102,7 @@ func Test_enqueueRequestsForServiceEvent_enqueueImpactedTargetGroupBindings(t *t
},
},
},
wantRequests: []ctrl.Request{
wantRequests: []reconcile.Request{
{
NamespacedName: types.NamespacedName{Namespace: "awesome-ns", Name: "tgb-1"},
},
Expand Down Expand Up @@ -161,7 +161,7 @@ func Test_enqueueRequestsForServiceEvent_enqueueImpactedTargetGroupBindings(t *t
},
},
},
wantRequests: []ctrl.Request{
wantRequests: []reconcile.Request{
{
NamespacedName: types.NamespacedName{Namespace: "awesome-ns", Name: "tgb-1"},
},
Expand Down Expand Up @@ -193,7 +193,7 @@ func Test_enqueueRequestsForServiceEvent_enqueueImpactedTargetGroupBindings(t *t
k8sClient: k8sClient,
logger: logr.New(&log.NullLogSink{}),
}
queue := &controllertest.Queue{Interface: workqueue.New()}
queue := &controllertest.TypedQueue[reconcile.Request]{TypedInterface: workqueue.NewTyped[reconcile.Request]()}
h.enqueueImpactedTargetGroupBindings(context.Background(), queue, tt.args.svc)
gotRequests := testutils.ExtractCTRLRequestsFromQueue(queue)
assert.True(t, cmp.Equal(tt.wantRequests, gotRequests),
Expand Down
7 changes: 4 additions & 3 deletions controllers/elbv2/targetgroupbinding_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"
discv1 "k8s.io/api/discovery/v1"
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"time"

"github.com/aws/aws-sdk-go-v2/aws"
Expand Down Expand Up @@ -91,12 +92,12 @@ type targetGroupBindingReconciler struct {
// +kubebuilder:rbac:groups="",resources=events,verbs=create;patch
// +kubebuilder:rbac:groups="discovery.k8s.io",resources=endpointslices,verbs=get;list;watch

func (r *targetGroupBindingReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
func (r *targetGroupBindingReconciler) Reconcile(ctx context.Context, req reconcile.Request) (ctrl.Result, error) {
r.logger.V(1).Info("Reconcile request", "name", req.Name)
return runtime.HandleReconcileError(r.reconcile(ctx, req), r.logger)
}

func (r *targetGroupBindingReconciler) reconcile(ctx context.Context, req ctrl.Request) error {
func (r *targetGroupBindingReconciler) reconcile(ctx context.Context, req reconcile.Request) error {
tgb := &elbv2api.TargetGroupBinding{}
if err := r.k8sClient.Get(ctx, req.NamespacedName, tgb); err != nil {
return client.IgnoreNotFound(err)
Expand Down Expand Up @@ -194,7 +195,7 @@ func (r *targetGroupBindingReconciler) SetupWithManager(ctx context.Context, mgr
Watches(&corev1.Node{}, nodeEventsHandler).
WithOptions(controller.Options{
MaxConcurrentReconciles: r.maxConcurrentReconciles,
RateLimiter: workqueue.NewItemExponentialFailureRateLimiter(5*time.Millisecond, r.maxExponentialBackoffDelay)}).
RateLimiter: workqueue.NewTypedItemExponentialFailureRateLimiter[reconcile.Request](5*time.Millisecond, r.maxExponentialBackoffDelay)}).
Complete(r)
}

Expand Down
Loading

0 comments on commit f1435b3

Please sign in to comment.