Skip to content

Commit ee3fc7a

Browse files
authored
Merge pull request #4104 from kellyyan/version-updates
Update Go to version 1.24.1, update base image to AL2023
2 parents 45ba355 + ca0a537 commit ee3fc7a

File tree

6 files changed

+85
-85
lines changed

6 files changed

+85
-85
lines changed

.go-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.23.6
1+
1.24.1

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ IMG ?= public.ecr.aws/eks/aws-load-balancer-controller:v2.12.0
77
GOLANG_VERSION ?= $(shell cat .go-version)
88
BUILD_IMAGE ?= public.ecr.aws/docker/library/golang:$(GOLANG_VERSION)
99
# Image URL to use for base layer in Docker build
10-
BASE_IMAGE ?= public.ecr.aws/eks-distro-build-tooling/eks-distro-minimal-base-nonroot:2024-08-13-1723575672.2
10+
BASE_IMAGE ?= public.ecr.aws/eks-distro-build-tooling/eks-distro-minimal-base-nonroot:2025-01-01-1735689705.2023
1111
IMG_PLATFORM ?= linux/amd64,linux/arm64
1212
# ECR doesn't appear to support SPDX SBOM
1313
IMG_SBOM ?= none

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module sigs.k8s.io/aws-load-balancer-controller
22

3-
go 1.23.6
3+
go 1.24.1
44

55
require (
66
github.com/aws/aws-sdk-go v1.55.5

pkg/networking/utils.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package networking
22

33
import (
4-
"fmt"
4+
"net/netip"
5+
"strings"
6+
57
awssdk "github.com/aws/aws-sdk-go-v2/aws"
68
ec2types "github.com/aws/aws-sdk-go-v2/service/ec2/types"
79
"github.com/pkg/errors"
8-
"net/netip"
910
elbv2model "sigs.k8s.io/aws-load-balancer-controller/pkg/model/elbv2"
10-
"strings"
1111
)
1212

1313
// ParseCIDRs will parse CIDRs in string format into parsed IPPrefix
@@ -80,30 +80,30 @@ func GetSubnetAssociatedIPv6CIDRs(subnet ec2types.Subnet) ([]netip.Prefix, error
8080
// ValidateEnablePrefixForIpv6SourceNat function returns the validation error if error exists for EnablePrefixForIpv6SourceNat annotation value
8181
func ValidateEnablePrefixForIpv6SourceNat(EnablePrefixForIpv6SourceNat string, ipAddressType elbv2model.IPAddressType, ec2Subnets []ec2types.Subnet) error {
8282
if EnablePrefixForIpv6SourceNat != string(elbv2model.EnablePrefixForIpv6SourceNatOn) && EnablePrefixForIpv6SourceNat != string(elbv2model.EnablePrefixForIpv6SourceNatOff) {
83-
return errors.Errorf(fmt.Sprintf("Invalid enable-prefix-for-ipv6-source-nat value: %v. Valid values are ['on', 'off'].", EnablePrefixForIpv6SourceNat))
83+
return errors.Errorf("Invalid enable-prefix-for-ipv6-source-nat value: %v. Valid values are ['on', 'off'].", EnablePrefixForIpv6SourceNat)
8484
}
8585

8686
if EnablePrefixForIpv6SourceNat != string(elbv2model.EnablePrefixForIpv6SourceNatOn) {
8787
return nil
8888
}
8989

9090
if ipAddressType == elbv2model.IPAddressTypeIPV4 {
91-
return errors.Errorf(fmt.Sprintf("enable-prefix-for-ipv6-source-nat annotation is only applicable to Network Load Balancers using Dualstack IP address type."))
91+
return errors.Errorf("enable-prefix-for-ipv6-source-nat annotation is only applicable to Network Load Balancers using Dualstack IP address type.")
9292
}
9393
var subnetsWithoutIPv6CIDR []string
9494

9595
for _, subnet := range ec2Subnets {
9696
subnetIPv6CIDRs, err := GetSubnetAssociatedIPv6CIDRs(subnet)
9797
if err != nil {
98-
return errors.Errorf(fmt.Sprintf("%v", err))
98+
return errors.Errorf("%v", err)
9999
}
100100
if len(subnetIPv6CIDRs) < 1 {
101101
subnetsWithoutIPv6CIDR = append(subnetsWithoutIPv6CIDR, awssdk.ToString(subnet.SubnetId))
102102

103103
}
104104
}
105105
if len(subnetsWithoutIPv6CIDR) > 0 {
106-
return errors.Errorf(fmt.Sprintf("To enable prefix for source NAT, all associated subnets must have an IPv6 CIDR. Subnets without IPv6 CIDR: %v.", subnetsWithoutIPv6CIDR))
106+
return errors.Errorf("To enable prefix for source NAT, all associated subnets must have an IPv6 CIDR. Subnets without IPv6 CIDR: %v.", subnetsWithoutIPv6CIDR)
107107
}
108108

109109
return nil
@@ -120,36 +120,36 @@ func ValidateSourceNatPrefixes(sourceNatIpv6Prefixes []string, ipAddressType elb
120120
}
121121

122122
if len(sourceNatIpv6Prefixes) != len(ec2Subnets) {
123-
return errors.Errorf(fmt.Sprintf("Number of values in source-nat-ipv6-prefixes (%d) must match the number of subnets (%d).", len(sourceNatIpv6Prefixes), len(ec2Subnets)))
123+
return errors.Errorf("Number of values in source-nat-ipv6-prefixes (%d) must match the number of subnets (%d).", len(sourceNatIpv6Prefixes), len(ec2Subnets))
124124
}
125125
for idx, sourceNatIpv6Prefix := range sourceNatIpv6Prefixes {
126126
var subnet = ec2Subnets[idx]
127127
var sourceNatIpv6PrefixParsedList []netip.Addr
128128
if sourceNatIpv6Prefix != elbv2model.SourceNatIpv6PrefixAutoAssigned {
129129
subStrings := strings.Split(sourceNatIpv6Prefix, "/")
130130
if len(subStrings) < 2 {
131-
return errors.Errorf(fmt.Sprintf("Invalid value in source-nat-ipv6-prefixes: %v.", sourceNatIpv6Prefix))
131+
return errors.Errorf("Invalid value in source-nat-ipv6-prefixes: %v.", sourceNatIpv6Prefix)
132132
}
133133
var ipAddressPart = subStrings[0]
134134
var prefixLengthPart = subStrings[1]
135135
if prefixLengthPart != requiredPrefixLengthForSourceNatCidr {
136-
return errors.Errorf(fmt.Sprintf("Invalid value in source-nat-ipv6-prefixes: %v. Prefix length must be %v, but %v is specified.", sourceNatIpv6Prefix, requiredPrefixLengthForSourceNatCidr, prefixLengthPart))
136+
return errors.Errorf("Invalid value in source-nat-ipv6-prefixes: %v. Prefix length must be %v, but %v is specified.", sourceNatIpv6Prefix, requiredPrefixLengthForSourceNatCidr, prefixLengthPart)
137137
}
138138
sourceNatIpv6PrefixNetIpParsed, err := netip.ParseAddr(ipAddressPart)
139139
if err != nil {
140-
return errors.Errorf(fmt.Sprintf("Invalid value in source-nat-ipv6-prefixes: %v. Value must be a valid IPv6 CIDR.", sourceNatIpv6Prefix))
140+
return errors.Errorf("Invalid value in source-nat-ipv6-prefixes: %v. Value must be a valid IPv6 CIDR.", sourceNatIpv6Prefix)
141141
}
142142
sourceNatIpv6PrefixParsedList = append(sourceNatIpv6PrefixParsedList, sourceNatIpv6PrefixNetIpParsed)
143143
if !sourceNatIpv6PrefixNetIpParsed.Is6() {
144-
return errors.Errorf(fmt.Sprintf("Invalid value in source-nat-ipv6-prefixes: %v. Value must be a valid IPv6 CIDR.", sourceNatIpv6Prefix))
144+
return errors.Errorf("Invalid value in source-nat-ipv6-prefixes: %v. Value must be a valid IPv6 CIDR.", sourceNatIpv6Prefix)
145145
}
146146
subnetIPv6CIDRs, err := GetSubnetAssociatedIPv6CIDRs(subnet)
147147
if err != nil {
148-
return errors.Errorf(fmt.Sprintf("Subnet has invalid IPv6 CIDRs: %v. Subnet must have valid IPv6 CIDRs.", subnetIPv6CIDRs))
148+
return errors.Errorf("Subnet has invalid IPv6 CIDRs: %v. Subnet must have valid IPv6 CIDRs.", subnetIPv6CIDRs)
149149
}
150150
sourceNatIpv6PrefixWithinSubnet := FilterIPsWithinCIDRs(sourceNatIpv6PrefixParsedList, subnetIPv6CIDRs)
151151
if len(sourceNatIpv6PrefixWithinSubnet) != 1 {
152-
return errors.Errorf(fmt.Sprintf("Invalid value in source-nat-ipv6-prefixes: %v. Value must be within subnet CIDR range: %v.", sourceNatIpv6Prefix, subnetIPv6CIDRs))
152+
return errors.Errorf("Invalid value in source-nat-ipv6-prefixes: %v. Value must be within subnet CIDR range: %v.", sourceNatIpv6Prefix, subnetIPv6CIDRs)
153153
}
154154
}
155155
}

pkg/service/model_build_target_group.go

Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -205,65 +205,65 @@ func (t *defaultModelBuildTask) buildTargetGroupName(_ context.Context, svcPort
205205
}
206206

207207
func (t *defaultModelBuildTask) buildTargetGroupAttributes(_ context.Context, port corev1.ServicePort) ([]elbv2model.TargetGroupAttribute, error) {
208-
var rawAttributes map[string]string
209-
if _, err := t.annotationParser.ParseStringMapAnnotation(annotations.SvcLBSuffixTargetGroupAttributes, &rawAttributes, t.service.Annotations); err != nil {
210-
return nil, err
211-
}
212-
if rawAttributes == nil {
213-
rawAttributes = make(map[string]string)
214-
}
215-
if _, ok := rawAttributes[tgAttrsProxyProtocolV2Enabled]; !ok {
216-
rawAttributes[tgAttrsProxyProtocolV2Enabled] = strconv.FormatBool(t.defaultProxyProtocolV2Enabled)
217-
}
218-
219-
var proxyProtocolPerTG string
220-
if t.annotationParser.ParseStringAnnotation(annotations.SvcLBSuffixProxyProtocolPerTargetGroup, &proxyProtocolPerTG, t.service.Annotations) {
221-
ports := strings.Split(proxyProtocolPerTG, ",")
222-
enabledPorts := make(map[string]struct{})
223-
for _, p := range ports {
224-
trimmedPort := strings.TrimSpace(p)
225-
if trimmedPort != "" {
226-
if _, err := strconv.Atoi(trimmedPort); err != nil {
227-
return nil, errors.Errorf("invalid port number in proxy-protocol-per-target-group: %v", trimmedPort)
228-
}
229-
enabledPorts[trimmedPort] = struct{}{}
230-
}
231-
}
232-
233-
currentPortStr := strconv.FormatInt(int64(port.Port), 10)
234-
if _, enabled := enabledPorts[currentPortStr]; enabled {
235-
rawAttributes[tgAttrsProxyProtocolV2Enabled] = "true"
236-
} else {
237-
rawAttributes[tgAttrsProxyProtocolV2Enabled] = "false"
238-
}
239-
}
240-
241-
proxyV2Annotation := ""
242-
if exists := t.annotationParser.ParseStringAnnotation(annotations.SvcLBSuffixProxyProtocol, &proxyV2Annotation, t.service.Annotations); exists {
243-
if proxyV2Annotation != "*" {
244-
return []elbv2model.TargetGroupAttribute{}, errors.Errorf("invalid value %v for Load Balancer proxy protocol v2 annotation, only value currently supported is *", proxyV2Annotation)
245-
}
246-
rawAttributes[tgAttrsProxyProtocolV2Enabled] = "true"
247-
}
248-
249-
if rawPreserveIPEnabled, ok := rawAttributes[tgAttrsPreserveClientIPEnabled]; ok {
250-
_, err := strconv.ParseBool(rawPreserveIPEnabled)
251-
if err != nil {
252-
return nil, errors.Wrapf(err, "failed to parse attribute %v=%v", tgAttrsPreserveClientIPEnabled, rawPreserveIPEnabled)
253-
}
254-
}
255-
256-
attributes := make([]elbv2model.TargetGroupAttribute, 0, len(rawAttributes))
257-
for attrKey, attrValue := range rawAttributes {
258-
attributes = append(attributes, elbv2model.TargetGroupAttribute{
259-
Key: attrKey,
260-
Value: attrValue,
261-
})
262-
}
263-
sort.Slice(attributes, func(i, j int) bool {
264-
return attributes[i].Key < attributes[j].Key
265-
})
266-
return attributes, nil
208+
var rawAttributes map[string]string
209+
if _, err := t.annotationParser.ParseStringMapAnnotation(annotations.SvcLBSuffixTargetGroupAttributes, &rawAttributes, t.service.Annotations); err != nil {
210+
return nil, err
211+
}
212+
if rawAttributes == nil {
213+
rawAttributes = make(map[string]string)
214+
}
215+
if _, ok := rawAttributes[tgAttrsProxyProtocolV2Enabled]; !ok {
216+
rawAttributes[tgAttrsProxyProtocolV2Enabled] = strconv.FormatBool(t.defaultProxyProtocolV2Enabled)
217+
}
218+
219+
var proxyProtocolPerTG string
220+
if t.annotationParser.ParseStringAnnotation(annotations.SvcLBSuffixProxyProtocolPerTargetGroup, &proxyProtocolPerTG, t.service.Annotations) {
221+
ports := strings.Split(proxyProtocolPerTG, ",")
222+
enabledPorts := make(map[string]struct{})
223+
for _, p := range ports {
224+
trimmedPort := strings.TrimSpace(p)
225+
if trimmedPort != "" {
226+
if _, err := strconv.Atoi(trimmedPort); err != nil {
227+
return nil, errors.Errorf("invalid port number in proxy-protocol-per-target-group: %v", trimmedPort)
228+
}
229+
enabledPorts[trimmedPort] = struct{}{}
230+
}
231+
}
232+
233+
currentPortStr := strconv.FormatInt(int64(port.Port), 10)
234+
if _, enabled := enabledPorts[currentPortStr]; enabled {
235+
rawAttributes[tgAttrsProxyProtocolV2Enabled] = "true"
236+
} else {
237+
rawAttributes[tgAttrsProxyProtocolV2Enabled] = "false"
238+
}
239+
}
240+
241+
proxyV2Annotation := ""
242+
if exists := t.annotationParser.ParseStringAnnotation(annotations.SvcLBSuffixProxyProtocol, &proxyV2Annotation, t.service.Annotations); exists {
243+
if proxyV2Annotation != "*" {
244+
return []elbv2model.TargetGroupAttribute{}, errors.Errorf("invalid value %v for Load Balancer proxy protocol v2 annotation, only value currently supported is *", proxyV2Annotation)
245+
}
246+
rawAttributes[tgAttrsProxyProtocolV2Enabled] = "true"
247+
}
248+
249+
if rawPreserveIPEnabled, ok := rawAttributes[tgAttrsPreserveClientIPEnabled]; ok {
250+
_, err := strconv.ParseBool(rawPreserveIPEnabled)
251+
if err != nil {
252+
return nil, errors.Wrapf(err, "failed to parse attribute %v=%v", tgAttrsPreserveClientIPEnabled, rawPreserveIPEnabled)
253+
}
254+
}
255+
256+
attributes := make([]elbv2model.TargetGroupAttribute, 0, len(rawAttributes))
257+
for attrKey, attrValue := range rawAttributes {
258+
attributes = append(attributes, elbv2model.TargetGroupAttribute{
259+
Key: attrKey,
260+
Value: attrValue,
261+
})
262+
}
263+
sort.Slice(attributes, func(i, j int) bool {
264+
return attributes[i].Key < attributes[j].Key
265+
})
266+
return attributes, nil
267267
}
268268

269269
func (t *defaultModelBuildTask) buildPreserveClientIPFlag(_ context.Context, targetType elbv2model.TargetType, tgAttrs []elbv2model.TargetGroupAttribute) (bool, error) {
@@ -736,4 +736,4 @@ func (t *defaultModelBuildTask) buildTargetGroupBindingMultiClusterFlag(svc *cor
736736
return rawEnabled, nil
737737
}
738738
return false, nil
739-
}
739+
}

pkg/service/model_build_target_group_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ package service
33
import (
44
"context"
55
"errors"
6+
"sort"
7+
"strconv"
8+
"testing"
9+
610
ec2types "github.com/aws/aws-sdk-go-v2/service/ec2/types"
711
"github.com/golang/mock/gomock"
812
"sigs.k8s.io/aws-load-balancer-controller/pkg/model/core"
913
"sigs.k8s.io/aws-load-balancer-controller/pkg/networking"
10-
"sort"
11-
"strconv"
12-
"testing"
1314

1415
"github.com/aws/aws-sdk-go-v2/aws"
1516
"github.com/stretchr/testify/assert"
@@ -146,15 +147,15 @@ func Test_defaultModelBuilderTask_targetGroupAttrs(t *testing.T) {
146147
svc: &corev1.Service{
147148
ObjectMeta: metav1.ObjectMeta{
148149
Annotations: map[string]string{
149-
"service.beta.kubernetes.io/aws-load-balancer-proxy-protocol-per-target-group": "80",
150+
"service.beta.kubernetes.io/aws-load-balancer-proxy-protocol-per-target-group": "80",
150151
},
151152
},
152153
},
153154
port: corev1.ServicePort{Port: 80},
154155
wantError: false,
155156
wantValue: []elbv2.TargetGroupAttribute{
156157
{
157-
Key: tgAttrsProxyProtocolV2Enabled,
158+
Key: tgAttrsProxyProtocolV2Enabled,
158159
Value: "true",
159160
},
160161
},
@@ -165,16 +166,15 @@ func Test_defaultModelBuilderTask_targetGroupAttrs(t *testing.T) {
165166
ObjectMeta: metav1.ObjectMeta{
166167
Annotations: map[string]string{
167168
"service.beta.kubernetes.io/aws-load-balancer-proxy-protocol-per-target-group": "443, 22",
168-
"service.beta.kubernetes.io/aws-load-balancer-proxy-protocol": "*",
169-
169+
"service.beta.kubernetes.io/aws-load-balancer-proxy-protocol": "*",
170170
},
171171
},
172172
},
173173
port: corev1.ServicePort{Port: 80},
174174
wantError: false,
175175
wantValue: []elbv2.TargetGroupAttribute{
176176
{
177-
Key: tgAttrsProxyProtocolV2Enabled,
177+
Key: tgAttrsProxyProtocolV2Enabled,
178178
Value: "true",
179179
},
180180
},

0 commit comments

Comments
 (0)