File tree Expand file tree Collapse file tree 2 files changed +13
-17
lines changed
Expand file tree Collapse file tree 2 files changed +13
-17
lines changed Original file line number Diff line number Diff line change @@ -993,23 +993,19 @@ func (c *Cloud) computeTargetGroupExpectedTargets(instances map[InstanceID]*ec2t
993993
994994 for instanceID , instance := range instances {
995995 if ipAddressType == elbv2types .TargetGroupIpAddressTypeEnumIpv6 {
996- // For IPv6 target groups, register using the instance's IPv6 address
996+ // For IPv6 target groups, verify instance has IPv6 address before registering
997997 ipv6Address := extractInstanceIPv6Address (instance )
998- if ipv6Address != "" {
999- expectedTargets = append (expectedTargets , & elbv2types.TargetDescription {
1000- Id : aws .String (ipv6Address ),
1001- Port : aws .Int32 (port ),
1002- })
1003- } else {
998+ if ipv6Address == "" {
1004999 klog .Warningf ("Instance %s has no IPv6 address, skipping registration to IPv6 target group" , instanceID )
1000+ continue
10051001 }
1006- } else {
1007- // For IPv4 target groups, register using the instance ID
1008- expectedTargets = append (expectedTargets , & elbv2types.TargetDescription {
1009- Id : aws .String (string (instanceID )),
1010- Port : aws .Int32 (port ),
1011- })
10121002 }
1003+ // Register using instance ID for both IPv4 and IPv6 target groups
1004+ // AWS will route to the appropriate IP address based on the target group's IpAddressType
1005+ expectedTargets = append (expectedTargets , & elbv2types.TargetDescription {
1006+ Id : aws .String (string (instanceID )),
1007+ Port : aws .Int32 (port ),
1008+ })
10131009 }
10141010 return expectedTargets
10151011}
Original file line number Diff line number Diff line change @@ -1100,7 +1100,7 @@ func TestCloud_computeTargetGroupExpectedTargets(t *testing.T) {
11001100 },
11011101 want : []* elbv2types.TargetDescription {
11021102 {
1103- Id : aws .String ("2001:db8::1 " ),
1103+ Id : aws .String ("i-abcdef1 " ),
11041104 Port : aws .Int32 (8080 ),
11051105 },
11061106 },
@@ -1151,15 +1151,15 @@ func TestCloud_computeTargetGroupExpectedTargets(t *testing.T) {
11511151 },
11521152 want : []* elbv2types.TargetDescription {
11531153 {
1154- Id : aws .String ("2001:db8::1 " ),
1154+ Id : aws .String ("i-abcdef1 " ),
11551155 Port : aws .Int32 (8080 ),
11561156 },
11571157 {
1158- Id : aws .String ("2001:db8::2 " ),
1158+ Id : aws .String ("i-abcdef2 " ),
11591159 Port : aws .Int32 (8080 ),
11601160 },
11611161 {
1162- Id : aws .String ("2001:db8::3 " ),
1162+ Id : aws .String ("i-abcdef3 " ),
11631163 Port : aws .Int32 (8080 ),
11641164 },
11651165 },
You can’t perform that action at this time.
0 commit comments