Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: EnablePrefixForIpv6SourceNat is only applicable to NLB #3958

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions pkg/deploy/elbv2/load_balancer_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package elbv2
import (
"context"
"fmt"

awssdk "github.com/aws/aws-sdk-go-v2/aws"
elbv2sdk "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2"
elbv2types "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2/types"
Expand Down Expand Up @@ -176,14 +177,15 @@ func (m *defaultLoadBalancerManager) updateSDKLoadBalancerWithSubnetMappings(ctx

resLBEnablePrefixForIpv6SourceNatValue = string(resLB.Spec.EnablePrefixForIpv6SourceNat)

if desiredSubnets.Equal(currentSubnets) && desiredSubnetsSourceNATPrefixes.Equal(currentSubnetsSourceNATPrefixes) && sdkLBEnablePrefixForIpv6SourceNatValue == resLBEnablePrefixForIpv6SourceNatValue {
if desiredSubnets.Equal(currentSubnets) && desiredSubnetsSourceNATPrefixes.Equal(currentSubnetsSourceNATPrefixes) && ((sdkLBEnablePrefixForIpv6SourceNatValue == resLBEnablePrefixForIpv6SourceNatValue) || (resLBEnablePrefixForIpv6SourceNatValue == "")) {
return nil
}

req := &elbv2sdk.SetSubnetsInput{
LoadBalancerArn: sdkLB.LoadBalancer.LoadBalancerArn,
SubnetMappings: buildSDKSubnetMappings(resLB.Spec.SubnetMappings),
EnablePrefixForIpv6SourceNat: elbv2types.EnablePrefixForIpv6SourceNatEnum(resLBEnablePrefixForIpv6SourceNatValue),
LoadBalancerArn: sdkLB.LoadBalancer.LoadBalancerArn,
SubnetMappings: buildSDKSubnetMappings(resLB.Spec.SubnetMappings),
}
if resLB.Spec.Type == elbv2model.LoadBalancerTypeNetwork {
req.EnablePrefixForIpv6SourceNat = elbv2types.EnablePrefixForIpv6SourceNatEnum(resLBEnablePrefixForIpv6SourceNatValue)
}
changeDesc := fmt.Sprintf("%v => %v", currentSubnets.List(), desiredSubnets.List())
m.logger.Info("modifying loadBalancer subnetMappings",
Expand Down
5 changes: 4 additions & 1 deletion pkg/deploy/elbv2/load_balancer_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package elbv2

import (
"context"
"testing"

elbv2types "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2/types"
"github.com/go-logr/logr"
"sigs.k8s.io/aws-load-balancer-controller/pkg/aws/services"
"testing"

awssdk "github.com/aws/aws-sdk-go-v2/aws"
elbv2sdk "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2"
Expand Down Expand Up @@ -552,6 +553,7 @@ func Test_defaultLoadBalancerManager_updateSDKLoadBalancerWithSubnetMappings(t *
resLB: &elbv2model.LoadBalancer{
ResourceMeta: coremodel.NewResourceMeta(stack, "AWS::ElasticLoadBalancingV2::LoadBalancer", "id-1"),
Spec: elbv2model.LoadBalancerSpec{
Type: elbv2model.LoadBalancerTypeNetwork,
EnablePrefixForIpv6SourceNat: enablePrefixForIpv6SourceNatOn,
SubnetMappings: []elbv2model.SubnetMapping{
{
Expand Down Expand Up @@ -591,6 +593,7 @@ func Test_defaultLoadBalancerManager_updateSDKLoadBalancerWithSubnetMappings(t *
resLB: &elbv2model.LoadBalancer{
ResourceMeta: coremodel.NewResourceMeta(stack, "AWS::ElasticLoadBalancingV2::LoadBalancer", "id-1"),
Spec: elbv2model.LoadBalancerSpec{
Type: elbv2model.LoadBalancerTypeNetwork,
SubnetMappings: []elbv2model.SubnetMapping{
{
SubnetID: "subnet-A",
Expand Down
Loading