Repository: kubernetes-sigs/cluster-api-provider-aws
Pull request #4566 (2023-10-10 20:05:27)

:bug: ELBv2 target groups should inherit tags
<!-- Thanks for this PR! If this is your first PR please read the [contributing guide](../CONTRIBUTING.md) -->
<!-- If this PR is still work-in-progress and is being open for visibility please prefix the title with `WIP:` -->

**What type of PR is this?**

<!--
Add one of the following kinds:
/kind feature
/kind bug
/kind api-change
/kind cleanup
/kind deprecation
/kind design
/kind documentation
/kind failing-test
/kind flake
/kind regression
/kind support
-->

**What this PR does / why we need it**:

/kind bug

<!-- Enter a description of the change and why this change is needed -->

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes #

**Special notes for your reviewer**:

**Checklist**:
<!-- Put an "X" character inside the brackets of each completed task. Some may be optional depending on the PR in which case these can be deleted -->

- [ ] squashed commits
- [ ] includes documentation
- [ ] adds unit tests
- [ ] adds or updates e2e tests

**Release note**:
<!--  Write your release note:
1. Enter your extended release note in the below block. If the PR requires additional action from users switching to the new release, include the string "action required".
2. If no release note is required, just write "NONE".
-->
```release-note
NONE
```



Patch:
diff --git a/pkg/cloud/services/elb/loadbalancer.go b/pkg/cloud/services/elb/loadbalancer.go
index 25af21c8d..925dd9fa0 100644
--- a/pkg/cloud/services/elb/loadbalancer.go
+++ b/pkg/cloud/services/elb/loadbalancer.go
@@ -273,6 +273,7 @@ func (s *Service) createLB(spec *infrav1.LoadBalancer) (*infrav1.LoadBalancer, e
 			Port:     aws.Int64(ln.TargetGroup.Port),
 			Protocol: aws.String(ln.TargetGroup.Protocol.String()),
 			VpcId:    aws.String(ln.TargetGroup.VpcID),
+			Tags:     input.Tags,
 		}
 		if s.scope.VPC().IsIPv6Enabled() {
 			targetGroupInput.IpAddressType = aws.String("ipv6")


Test patch:
diff --git a/pkg/cloud/services/elb/loadbalancer_test.go b/pkg/cloud/services/elb/loadbalancer_test.go
index ec5d8e0e8..541667db8 100644
--- a/pkg/cloud/services/elb/loadbalancer_test.go
+++ b/pkg/cloud/services/elb/loadbalancer_test.go
@@ -1047,6 +1047,12 @@ func TestCreateNLB(t *testing.T) {
 					Port:                aws.Int64(infrav1.DefaultAPIServerPort),
 					Protocol:            aws.String("TCP"),
 					VpcId:               aws.String(vpcID),
+					Tags: []*elbv2.Tag{
+						{
+							Key:   aws.String("test"),
+							Value: aws.String("tag"),
+						},
+					},
 				})).Return(&elbv2.CreateTargetGroupOutput{
 					TargetGroups: []*elbv2.TargetGroup{
 						{
@@ -1143,6 +1149,12 @@ func TestCreateNLB(t *testing.T) {
 					Protocol:            aws.String("TCP"),
 					VpcId:               aws.String(vpcID),
 					IpAddressType:       aws.String("ipv6"),
+					Tags: []*elbv2.Tag{
+						{
+							Key:   aws.String("test"),
+							Value: aws.String("tag"),
+						},
+					},
 				})).Return(&elbv2.CreateTargetGroupOutput{
 					TargetGroups: []*elbv2.TargetGroup{
 						{
@@ -1274,6 +1286,12 @@ func TestCreateNLB(t *testing.T) {
 					Port:     aws.Int64(infrav1.DefaultAPIServerPort),
 					Protocol: aws.String("TCP"),
 					VpcId:    aws.String(vpcID),
+					Tags: []*elbv2.Tag{
+						{
+							Key:   aws.String("test"),
+							Value: aws.String("tag"),
+						},
+					},
 				})).Return(&elbv2.CreateTargetGroupOutput{
 					TargetGroups: []*elbv2.TargetGroup{
 						{
@@ -1365,6 +1383,12 @@ func TestCreateNLB(t *testing.T) {
 					Port:                aws.Int64(infrav1.DefaultAPIServerPort),
 					Protocol:            aws.String("TCP"),
 					VpcId:               aws.String(vpcID),
+					Tags: []*elbv2.Tag{
+						{
+							Key:   aws.String("test"),
+							Value: aws.String("tag"),
+						},
+					},
 				})).Return(&elbv2.CreateTargetGroupOutput{
 					TargetGroups: []*elbv2.TargetGroup{
 						{
@@ -1449,6 +1473,12 @@ func TestCreateNLB(t *testing.T) {
 					Port:                aws.Int64(infrav1.DefaultAPIServerPort),
 					Protocol:            aws.String("TCP"),
 					VpcId:               aws.String(vpcID),
+					Tags: []*elbv2.Tag{
+						{
+							Key:   aws.String("test"),
+							Value: aws.String("tag"),
+						},
+					},
 				})).Return(&elbv2.CreateTargetGroupOutput{
 					TargetGroups: []*elbv2.TargetGroup{
 						{
diff --git a/scripts/ci-e2e.sh b/scripts/ci-e2e.sh
index ac8c6f888..5ddcc697a 100755
--- a/scripts/ci-e2e.sh
+++ b/scripts/ci-e2e.sh
@@ -48,8 +48,13 @@ cleanup() {
 trap cleanup EXIT
 
 # Ensure that python3-pip is installed.
-apt-get update
-apt-get install -y python3-pip python3-requests
+apt update
+apt install -y python3-pip
+rm -rf /var/lib/apt/lists/*
+
+# Install/upgrade pip and requests module explicitly for HTTP calls.
+apt update
+apt install -y python3-pip python3-requests
 
 # If BOSKOS_HOST is set then acquire an AWS account from Boskos.
 if [ -n "${BOSKOS_HOST:-}" ]; then