Skip to content

Commit d4419fe

Browse files
authored
Merge pull request #4502 from wweiwei-li/aga-fix
Add check for duplicate endpoints
2 parents 618afa5 + 48b5280 commit d4419fe

File tree

16 files changed

+267
-15
lines changed

16 files changed

+267
-15
lines changed

apis/aga/v1beta1/globalaccelerator_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ type IPSet struct {
279279
// +kubebuilder:object:root=true
280280
// +kubebuilder:subresource:status
281281
// +kubebuilder:storageversion
282-
// +kubebuilder:printcolumn:name="NAME",type="string",JSONPath=".spec.name",description="The Global Accelerator name"
282+
// +kubebuilder:printcolumn:name="ACCELERATOR-NAME",type="string",JSONPath=".spec.name",description="The Global Accelerator name"
283283
// +kubebuilder:printcolumn:name="DNS-NAME",type="string",JSONPath=".status.dnsName",description="The Global Accelerator DNS name"
284284
// +kubebuilder:printcolumn:name="TYPE",type="string",JSONPath=".spec.type",description="The Global Accelerator type"
285285
// +kubebuilder:printcolumn:name="STATUS",type="string",JSONPath=".status.status",description="The Global Accelerator status"

config/crd/aga/aga-crds.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ spec:
1717
- additionalPrinterColumns:
1818
- description: The Global Accelerator name
1919
jsonPath: .spec.name
20-
name: NAME
20+
name: ACCELERATOR-NAME
2121
type: string
2222
- description: The Global Accelerator DNS name
2323
jsonPath: .status.dnsName

config/crd/aga/aga.k8s.aws_globalaccelerators.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ spec:
1717
- additionalPrinterColumns:
1818
- description: The Global Accelerator name
1919
jsonPath: .spec.name
20-
name: NAME
20+
name: ACCELERATOR-NAME
2121
type: string
2222
- description: The Global Accelerator DNS name
2323
jsonPath: .status.dnsName

helm/aws-load-balancer-controller/crds/aga-crds.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ spec:
1717
- additionalPrinterColumns:
1818
- description: The Global Accelerator name
1919
jsonPath: .spec.name
20-
name: NAME
20+
name: ACCELERATOR-NAME
2121
type: string
2222
- description: The Global Accelerator DNS name
2323
jsonPath: .status.dnsName

helm/aws-load-balancer-controller/templates/webhook.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,36 @@ webhooks:
326326
- ingresses
327327
sideEffects: None
328328
{{- end }}
329+
{{- if .Values.controllerConfig.featureGates.GlobalAcceleratorController }}
330+
- clientConfig:
331+
{{- if not $.Values.enableCertManager }}
332+
caBundle: {{ $tls.caCert }}
333+
{{- end }}
334+
service:
335+
name: {{ template "aws-load-balancer-controller.webhookService" . }}
336+
namespace: {{ $.Release.Namespace }}
337+
path: /validate-aga-k8s-aws-v1beta1-globalaccelerator
338+
port: 443
339+
failurePolicy: Fail
340+
matchPolicy: Equivalent
341+
name: vglobalaccelerator.aga.k8s.aws
342+
admissionReviewVersions:
343+
- v1beta1
344+
namespaceSelector: {}
345+
objectSelector: {}
346+
rules:
347+
- apiGroups:
348+
- aga.k8s.aws
349+
apiVersions:
350+
- v1beta1
351+
operations:
352+
- CREATE
353+
- UPDATE
354+
resources:
355+
- globalaccelerators
356+
sideEffects: None
357+
timeoutSeconds: 10
358+
{{- end }}
329359
---
330360
{{- if not $.Values.enableCertManager }}
331361
apiVersion: v1

pkg/deploy/aga/accelerator_manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func (m *defaultAcceleratorManager) Update(ctx context.Context, resAccelerator *
118118

119119
var updatedAccelerator *agatypes.Accelerator
120120
if !m.isSDKAcceleratorSettingsDrifted(resAccelerator, sdkAccelerator) {
121-
m.logger.Info("No drift detected in accelerator settings, skipping update",
121+
m.logger.V(1).Info("No drift detected in accelerator settings, skipping update",
122122
"stackID", resAccelerator.Stack().StackID(),
123123
"resourceID", resAccelerator.ID(),
124124
"acceleratorARN", *sdkAccelerator.Accelerator.AcceleratorArn)

pkg/deploy/aga/endpoint_group_manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func (m *defaultEndpointGroupManager) buildSDKUpdateEndpointGroupInput(_ context
146146
func (m *defaultEndpointGroupManager) Update(ctx context.Context, resEndpointGroup *agamodel.EndpointGroup, sdkEndpointGroup *agatypes.EndpointGroup) (agamodel.EndpointGroupStatus, error) {
147147
// Check if the endpoint group actually needs an update
148148
if !m.isSDKEndpointGroupSettingsDrifted(resEndpointGroup, sdkEndpointGroup) {
149-
m.logger.Info("No drift detected in endpoint group settings, skipping update",
149+
m.logger.V(1).Info("No drift detected in endpoint group settings, skipping update",
150150
"stackID", resEndpointGroup.Stack().StackID(),
151151
"resourceID", resEndpointGroup.ID(),
152152
"endpointGroupARN", *sdkEndpointGroup.EndpointGroupArn)

pkg/deploy/aga/listener_manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func (m *defaultListenerManager) buildSDKUpdateListenerInput(ctx context.Context
131131
func (m *defaultListenerManager) Update(ctx context.Context, resListener *agamodel.Listener, sdkListener *ListenerResource) (agamodel.ListenerStatus, error) {
132132
// Check if the listener actually needs an update
133133
if !m.isSDKListenerSettingsDrifted(resListener, sdkListener) {
134-
m.logger.Info("No drift detected in listener settings, skipping update",
134+
m.logger.V(1).Info("No drift detected in listener settings, skipping update",
135135
"stackID", resListener.Stack().StackID(),
136136
"resourceID", resListener.ID(),
137137
"listenerARN", *sdkListener.Listener.ListenerArn)

test/e2e/gateway/common_resource_stack.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
appsv1 "k8s.io/api/apps/v1"
66
corev1 "k8s.io/api/core/v1"
7+
apierrors "k8s.io/apimachinery/pkg/api/errors"
78
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
89
"k8s.io/apimachinery/pkg/util/wait"
910
elbv2gw "sigs.k8s.io/aws-load-balancer-controller/apis/gateway/v1beta1"
@@ -208,7 +209,14 @@ func deleteReferenceGrants(ctx context.Context, f *framework.Framework, refGrant
208209

209210
func createGatewayClass(ctx context.Context, f *framework.Framework, gwc *gwv1.GatewayClass) error {
210211
f.Logger.Info("creating gateway class", "gwc", k8s.NamespacedName(gwc))
211-
return f.K8sClient.Create(ctx, gwc)
212+
err := f.K8sClient.Create(ctx, gwc)
213+
if err != nil && !apierrors.IsAlreadyExists(err) {
214+
return err
215+
}
216+
if apierrors.IsAlreadyExists(err) {
217+
f.Logger.Info("gateway class already exists", "gwc", k8s.NamespacedName(gwc))
218+
}
219+
return nil
212220
}
213221

214222
func createLoadBalancerConfig(ctx context.Context, f *framework.Framework, lbc *elbv2gw.LoadBalancerConfiguration) error {

test/e2e/globalaccelerator/aga_verifier.go

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,21 @@ type GlobalAcceleratorExpectation struct {
4747
Listeners []ListenerExpectation
4848
}
4949

50+
func matchesListener(listener *types.Listener, expected ListenerExpectation) bool {
51+
if expected.Protocol != "" && string(listener.Protocol) != expected.Protocol {
52+
return false
53+
}
54+
if len(expected.PortRanges) > 0 {
55+
if len(listener.PortRanges) == 0 {
56+
return false
57+
}
58+
if awssdk.ToInt32(listener.PortRanges[0].FromPort) != expected.PortRanges[0].FromPort {
59+
return false
60+
}
61+
}
62+
return true
63+
}
64+
5065
func verifyGlobalAcceleratorConfiguration(ctx context.Context, f *framework.Framework, acceleratorARN string, expected GlobalAcceleratorExpectation) error {
5166
agaClient := f.Cloud.GlobalAccelerator()
5267

@@ -79,8 +94,25 @@ func verifyGlobalAcceleratorConfiguration(ctx context.Context, f *framework.Fram
7994
return fmt.Errorf("listener count mismatch: expected %d, got %d", len(expected.Listeners), len(listListenersResp.Listeners))
8095
}
8196

97+
// Verify each expected listener exists (order-independent)
98+
matched := make(map[int]bool)
8299
for i, expectedListener := range expected.Listeners {
83-
listener := listListenersResp.Listeners[i]
100+
var listener *types.Listener
101+
var matchedIdx int
102+
for j := range listListenersResp.Listeners {
103+
if !matched[j] && matchesListener(&listListenersResp.Listeners[j], expectedListener) {
104+
listener = &listListenersResp.Listeners[j]
105+
matchedIdx = j
106+
break
107+
}
108+
}
109+
if listener == nil {
110+
if len(expectedListener.PortRanges) > 0 {
111+
return fmt.Errorf("expected listener[%d] with port %d not found", i, expectedListener.PortRanges[0].FromPort)
112+
}
113+
return fmt.Errorf("expected listener[%d] not found", i)
114+
}
115+
matched[matchedIdx] = true
84116

85117
if expectedListener.Protocol != "" && string(listener.Protocol) != expectedListener.Protocol {
86118
return fmt.Errorf("listener[%d] protocol mismatch: expected %s, got %s", i, expectedListener.Protocol, string(listener.Protocol))

0 commit comments

Comments
 (0)