Skip to content

Commit e5c21db

Browse files
authored
Update go to v1.22, controller-runtime dependency to v0.18.2, and kubernetes libs to v0.30.0 (#3707)
* go version, dep version * refactor for controller-runtime udpate * update tests, fix if statement the controller-runtime strips DeletionTimestamp from manifests on Create(). kubernetes-sigs/controller-runtime#2316 * refactor tests * remove placeholder comments * remove reconciler from WithOptions * remove DefaultNamespace cache option * remote `&& !hasGroupFinalizer` This was causing e2e tests to fail when an ingress did not have the group finalizer. The unit tests ing-1_been_deleted, and ing-6_been_deleted will need reworked due to changes in the controller-runtime that cause them to fail. * update unit tests for ctrl client/fake >0.15 controller-runtime >=0.15 does not support creating (or adding the field via Update()) objects with a DeletionTimestamp. To work around this we add an annotation `unit-test/delete` to mark the ingresses that we want to test deletion. We check for this annotation and then call Delete(). This will set the DeletionTimestamp to the current date and time so we use IgnoreOtherFields to skip then comparing want to got. relevant controller-runtime discussion/pr: - kubernetes-sigs/controller-runtime#2184 (comment) - kubernetes-sigs/controller-runtime#2316 * remove unused contexts * add DefaultNamespaces cache config * set opt.Cache.DefaultNamespaces conditionally If WatchNamespace is set to corev1.NamespaceAll we should not set DefaultNamespaces. This code assumes that only one namespace is specified for WatchNamespace. That decision was based on the help text for the flag `watch-namespace`. Related controller-runtime issue: kubernetes-sigs/controller-runtime#2628 * make crds * set go to v1.22.3
1 parent 9e9432b commit e5c21db

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+717
-1080
lines changed

.go-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.21.9
1+
1.22.3

config/crd/bases/elbv2.k8s.aws_ingressclassparams.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,13 @@ spec:
134134
items:
135135
type: string
136136
type: array
137+
x-kubernetes-list-type: atomic
137138
required:
138139
- key
139140
- operator
140141
type: object
141142
type: array
143+
x-kubernetes-list-type: atomic
142144
matchLabels:
143145
additionalProperties:
144146
type: string

config/crd/bases/elbv2.k8s.aws_targetgroupbindings.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,11 +342,13 @@ spec:
342342
items:
343343
type: string
344344
type: array
345+
x-kubernetes-list-type: atomic
345346
required:
346347
- key
347348
- operator
348349
type: object
349350
type: array
351+
x-kubernetes-list-type: atomic
350352
matchLabels:
351353
additionalProperties:
352354
type: string

config/webhook/manifests.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
---
21
apiVersion: admissionregistration.k8s.io/v1
32
kind: MutatingWebhookConfiguration
43
metadata:

controllers/elbv2/eventhandlers/endpoints.go

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

33
import (
44
"context"
5+
56
"github.com/go-logr/logr"
67
corev1 "k8s.io/api/core/v1"
78
"k8s.io/apimachinery/pkg/api/equality"
@@ -32,13 +33,13 @@ type enqueueRequestsForEndpointsEvent struct {
3233
}
3334

3435
// Create is called in response to an create event - e.g. Pod Creation.
35-
func (h *enqueueRequestsForEndpointsEvent) Create(e event.CreateEvent, queue workqueue.RateLimitingInterface) {
36+
func (h *enqueueRequestsForEndpointsEvent) Create(ctx context.Context, e event.CreateEvent, queue workqueue.RateLimitingInterface) {
3637
epNew := e.Object.(*corev1.Endpoints)
3738
h.enqueueImpactedTargetGroupBindings(queue, epNew)
3839
}
3940

4041
// Update is called in response to an update event - e.g. Pod Updated.
41-
func (h *enqueueRequestsForEndpointsEvent) Update(e event.UpdateEvent, queue workqueue.RateLimitingInterface) {
42+
func (h *enqueueRequestsForEndpointsEvent) Update(ctx context.Context, e event.UpdateEvent, queue workqueue.RateLimitingInterface) {
4243
epOld := e.ObjectOld.(*corev1.Endpoints)
4344
epNew := e.ObjectNew.(*corev1.Endpoints)
4445
if !equality.Semantic.DeepEqual(epOld.Subsets, epNew.Subsets) {
@@ -47,14 +48,14 @@ func (h *enqueueRequestsForEndpointsEvent) Update(e event.UpdateEvent, queue wor
4748
}
4849

4950
// Delete is called in response to a delete event - e.g. Pod Deleted.
50-
func (h *enqueueRequestsForEndpointsEvent) Delete(e event.DeleteEvent, queue workqueue.RateLimitingInterface) {
51+
func (h *enqueueRequestsForEndpointsEvent) Delete(ctx context.Context, e event.DeleteEvent, queue workqueue.RateLimitingInterface) {
5152
epOld := e.Object.(*corev1.Endpoints)
5253
h.enqueueImpactedTargetGroupBindings(queue, epOld)
5354
}
5455

5556
// Generic is called in response to an event of an unknown type or a synthetic event triggered as a cron or
5657
// external trigger request - e.g. reconcile AutoScaling, or a WebHook.
57-
func (h *enqueueRequestsForEndpointsEvent) Generic(event.GenericEvent, workqueue.RateLimitingInterface) {
58+
func (h *enqueueRequestsForEndpointsEvent) Generic(context.Context, event.GenericEvent, workqueue.RateLimitingInterface) {
5859
}
5960

6061
func (h *enqueueRequestsForEndpointsEvent) enqueueImpactedTargetGroupBindings(queue workqueue.RateLimitingInterface, ep *corev1.Endpoints) {

controllers/elbv2/eventhandlers/endpoints_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ func Test_enqueueRequestsForEndpointsEvent_enqueueImpactedTargetGroupBindings(t
172172
k8sClient: k8sClient,
173173
logger: logr.New(&log.NullLogSink{}),
174174
}
175-
queue := controllertest.Queue{Interface: workqueue.New()}
175+
queue := &controllertest.Queue{Interface: workqueue.New()}
176176
h.enqueueImpactedTargetGroupBindings(queue, tt.args.eps)
177177
gotRequests := testutils.ExtractCTRLRequestsFromQueue(queue)
178178
assert.True(t, cmp.Equal(tt.wantRequests, gotRequests),

controllers/elbv2/eventhandlers/endpointslices.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,36 +36,36 @@ type enqueueRequestsForEndpointSlicesEvent struct {
3636
}
3737

3838
// Create is called in response to an create event - e.g. EndpointSlice Creation.
39-
func (h *enqueueRequestsForEndpointSlicesEvent) Create(e event.CreateEvent, queue workqueue.RateLimitingInterface) {
39+
func (h *enqueueRequestsForEndpointSlicesEvent) Create(ctx context.Context, e event.CreateEvent, queue workqueue.RateLimitingInterface) {
4040
epNew := e.Object.(*discv1.EndpointSlice)
4141
h.logger.V(1).Info("Create event for EndpointSlices", "name", epNew.Name)
42-
h.enqueueImpactedTargetGroupBindings(queue, epNew)
42+
h.enqueueImpactedTargetGroupBindings(ctx, queue, epNew)
4343
}
4444

4545
// Update is called in response to an update event - e.g. EndpointSlice Updated.
46-
func (h *enqueueRequestsForEndpointSlicesEvent) Update(e event.UpdateEvent, queue workqueue.RateLimitingInterface) {
46+
func (h *enqueueRequestsForEndpointSlicesEvent) Update(ctx context.Context, e event.UpdateEvent, queue workqueue.RateLimitingInterface) {
4747
epOld := e.ObjectOld.(*discv1.EndpointSlice)
4848
epNew := e.ObjectNew.(*discv1.EndpointSlice)
4949
h.logger.V(1).Info("Update event for EndpointSlices", "name", epNew.Name)
5050
if !equality.Semantic.DeepEqual(epOld.Ports, epNew.Ports) || !equality.Semantic.DeepEqual(epOld.Endpoints, epNew.Endpoints) {
5151
h.logger.V(1).Info("Enqueue EndpointSlice", "name", epNew.Name)
52-
h.enqueueImpactedTargetGroupBindings(queue, epNew)
52+
h.enqueueImpactedTargetGroupBindings(ctx, queue, epNew)
5353
}
5454
}
5555

5656
// Delete is called in response to a delete event - e.g. EndpointSlice Deleted.
57-
func (h *enqueueRequestsForEndpointSlicesEvent) Delete(e event.DeleteEvent, queue workqueue.RateLimitingInterface) {
57+
func (h *enqueueRequestsForEndpointSlicesEvent) Delete(ctx context.Context, e event.DeleteEvent, queue workqueue.RateLimitingInterface) {
5858
epOld := e.Object.(*discv1.EndpointSlice)
5959
h.logger.V(1).Info("Deletion event for EndpointSlices", "name", epOld.Name)
60-
h.enqueueImpactedTargetGroupBindings(queue, epOld)
60+
h.enqueueImpactedTargetGroupBindings(ctx, queue, epOld)
6161
}
6262

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

68-
func (h *enqueueRequestsForEndpointSlicesEvent) enqueueImpactedTargetGroupBindings(queue workqueue.RateLimitingInterface, epSlice *discv1.EndpointSlice) {
68+
func (h *enqueueRequestsForEndpointSlicesEvent) enqueueImpactedTargetGroupBindings(ctx context.Context, queue workqueue.RateLimitingInterface, epSlice *discv1.EndpointSlice) {
6969
tgbList := &elbv2api.TargetGroupBindingList{}
7070
svcName, present := epSlice.Labels[svcNameLabel]
7171
if !present {

controllers/elbv2/eventhandlers/endpointslices_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ func Test_enqueueRequestsForEndpointSlicesEvent_enqueueImpactedTargetGroupBindin
174174
k8sClient: k8sClient,
175175
logger: logr.New(&log.NullLogSink{}),
176176
}
177-
queue := controllertest.Queue{Interface: workqueue.New()}
178-
h.enqueueImpactedTargetGroupBindings(queue, tt.args.epslice)
177+
queue := &controllertest.Queue{Interface: workqueue.New()}
178+
h.enqueueImpactedTargetGroupBindings(context.Background(), queue, tt.args.epslice)
179179
gotRequests := testutils.ExtractCTRLRequestsFromQueue(queue)
180180
assert.True(t, cmp.Equal(tt.wantRequests, gotRequests),
181181
"diff", cmp.Diff(tt.wantRequests, gotRequests))

controllers/elbv2/eventhandlers/node.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,32 +31,32 @@ type enqueueRequestsForNodeEvent struct {
3131
}
3232

3333
// Create is called in response to an create event - e.g. Pod Creation.
34-
func (h *enqueueRequestsForNodeEvent) Create(e event.CreateEvent, queue workqueue.RateLimitingInterface) {
34+
func (h *enqueueRequestsForNodeEvent) Create(ctx context.Context, e event.CreateEvent, queue workqueue.RateLimitingInterface) {
3535
nodeNew := e.Object.(*corev1.Node)
36-
h.enqueueImpactedTargetGroupBindings(queue, nil, nodeNew)
36+
h.enqueueImpactedTargetGroupBindings(ctx, queue, nil, nodeNew)
3737
}
3838

3939
// Update is called in response to an update event - e.g. Pod Updated.
40-
func (h *enqueueRequestsForNodeEvent) Update(e event.UpdateEvent, queue workqueue.RateLimitingInterface) {
40+
func (h *enqueueRequestsForNodeEvent) Update(ctx context.Context, e event.UpdateEvent, queue workqueue.RateLimitingInterface) {
4141
nodeOld := e.ObjectOld.(*corev1.Node)
4242
nodeNew := e.ObjectNew.(*corev1.Node)
43-
h.enqueueImpactedTargetGroupBindings(queue, nodeOld, nodeNew)
43+
h.enqueueImpactedTargetGroupBindings(ctx, queue, nodeOld, nodeNew)
4444
}
4545

4646
// Delete is called in response to a delete event - e.g. Pod Deleted.
47-
func (h *enqueueRequestsForNodeEvent) Delete(e event.DeleteEvent, queue workqueue.RateLimitingInterface) {
47+
func (h *enqueueRequestsForNodeEvent) Delete(ctx context.Context, e event.DeleteEvent, queue workqueue.RateLimitingInterface) {
4848
nodeOld := e.Object.(*corev1.Node)
49-
h.enqueueImpactedTargetGroupBindings(queue, nodeOld, nil)
49+
h.enqueueImpactedTargetGroupBindings(ctx, queue, nodeOld, nil)
5050
}
5151

5252
// Generic is called in response to an event of an unknown type or a synthetic event triggered as a cron or
5353
// external trigger request - e.g. reconcile AutoScaling, or a WebHook.
54-
func (h *enqueueRequestsForNodeEvent) Generic(e event.GenericEvent, queue workqueue.RateLimitingInterface) {
54+
func (h *enqueueRequestsForNodeEvent) Generic(context.Context, event.GenericEvent, workqueue.RateLimitingInterface) {
5555
// nothing to do here
5656
}
5757

5858
// enqueueImpactedTargetGroupBindings will enqueue all impacted TargetGroupBindings for node events.
59-
func (h *enqueueRequestsForNodeEvent) enqueueImpactedTargetGroupBindings(queue workqueue.RateLimitingInterface, nodeOld *corev1.Node, nodeNew *corev1.Node) {
59+
func (h *enqueueRequestsForNodeEvent) enqueueImpactedTargetGroupBindings(ctx context.Context, queue workqueue.RateLimitingInterface, nodeOld *corev1.Node, nodeNew *corev1.Node) {
6060
var nodeKey types.NamespacedName
6161
nodeOldSuitableAsTrafficProxy := false
6262
nodeNewSuitableAsTrafficProxy := false

controllers/elbv2/eventhandlers/service.go

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

33
import (
44
"context"
5+
56
"github.com/go-logr/logr"
67
corev1 "k8s.io/api/core/v1"
78
"k8s.io/apimachinery/pkg/api/equality"
@@ -30,34 +31,34 @@ type enqueueRequestsForServiceEvent struct {
3031
}
3132

3233
// Create is called in response to an create event - e.g. Pod Creation.
33-
func (h *enqueueRequestsForServiceEvent) Create(e event.CreateEvent, queue workqueue.RateLimitingInterface) {
34+
func (h *enqueueRequestsForServiceEvent) Create(ctx context.Context, e event.CreateEvent, queue workqueue.RateLimitingInterface) {
3435
svcNew := e.Object.(*corev1.Service)
35-
h.enqueueImpactedTargetGroupBindings(queue, svcNew)
36+
h.enqueueImpactedTargetGroupBindings(ctx, queue, svcNew)
3637
}
3738

3839
// Update is called in response to an update event - e.g. Pod Updated.
39-
func (h *enqueueRequestsForServiceEvent) Update(e event.UpdateEvent, queue workqueue.RateLimitingInterface) {
40+
func (h *enqueueRequestsForServiceEvent) Update(ctx context.Context, e event.UpdateEvent, queue workqueue.RateLimitingInterface) {
4041
svcOld := e.ObjectOld.(*corev1.Service)
4142
svcNew := e.ObjectNew.(*corev1.Service)
4243
if !equality.Semantic.DeepEqual(svcOld.Spec.Ports, svcNew.Spec.Ports) {
43-
h.enqueueImpactedTargetGroupBindings(queue, svcNew)
44+
h.enqueueImpactedTargetGroupBindings(ctx, queue, svcNew)
4445
}
4546
}
4647

4748
// Delete is called in response to a delete event - e.g. Pod Deleted.
48-
func (h *enqueueRequestsForServiceEvent) Delete(e event.DeleteEvent, queue workqueue.RateLimitingInterface) {
49+
func (h *enqueueRequestsForServiceEvent) Delete(ctx context.Context, e event.DeleteEvent, queue workqueue.RateLimitingInterface) {
4950
svcOld := e.Object.(*corev1.Service)
50-
h.enqueueImpactedTargetGroupBindings(queue, svcOld)
51+
h.enqueueImpactedTargetGroupBindings(ctx, queue, svcOld)
5152
}
5253

5354
// Generic is called in response to an event of an unknown type or a synthetic event triggered as a cron or
5455
// external trigger request - e.g. reconcile AutoScaling, or a WebHook.
55-
func (h *enqueueRequestsForServiceEvent) Generic(e event.GenericEvent, queue workqueue.RateLimitingInterface) {
56+
func (h *enqueueRequestsForServiceEvent) Generic(context.Context, event.GenericEvent, workqueue.RateLimitingInterface) {
5657
// nothing to do here
5758
}
5859

5960
// enqueueImpactedEndpointBindings will enqueue all impacted TargetGroupBindings for service events.
60-
func (h *enqueueRequestsForServiceEvent) enqueueImpactedTargetGroupBindings(queue workqueue.RateLimitingInterface, svc *corev1.Service) {
61+
func (h *enqueueRequestsForServiceEvent) enqueueImpactedTargetGroupBindings(ctx context.Context, queue workqueue.RateLimitingInterface, svc *corev1.Service) {
6162
tgbList := &elbv2api.TargetGroupBindingList{}
6263
if err := h.k8sClient.List(context.Background(), tgbList,
6364
client.InNamespace(svc.Namespace),

0 commit comments

Comments
 (0)