@@ -100,8 +100,9 @@ func (t *targetGroupBuilderImpl) buildTargetGroup(stack core.Stack,
100
100
gw * gwv1.Gateway , lbConfig elbv2gw.LoadBalancerConfiguration , lbIPType elbv2model.IPAddressType , routeDescriptor routeutils.RouteDescriptor , backend routeutils.Backend , backendSGIDToken core.StringToken ) (* elbv2model.TargetGroup , error ) {
101
101
102
102
targetGroupProps := backend .ELBV2TargetGroupProps
103
- tgResID := t .buildTargetGroupResourceID (k8s .NamespacedName (gw ), k8s .NamespacedName (backend .Service ), routeDescriptor .GetRouteNamespacedName (), backend .ServicePort .TargetPort )
103
+ tgResID := t .buildTargetGroupResourceID (k8s .NamespacedName (gw ), k8s .NamespacedName (backend .Service ), routeDescriptor .GetRouteNamespacedName (), routeDescriptor . GetRouteKind (), backend .ServicePort .TargetPort )
104
104
if tg , exists := t .tgByResID [tgResID ]; exists {
105
+ fmt .Println ("TG already exists. Returning cached version" )
105
106
return tg , nil
106
107
}
107
108
@@ -129,7 +130,7 @@ func (builder *targetGroupBuilderImpl) buildTargetGroupBindingSpec(gw *gwv1.Gate
129
130
if targetType == elbv2api .TargetTypeInstance {
130
131
targetPort = intstr .FromInt32 (backend .ServicePort .NodePort )
131
132
}
132
- tgbNetworking := builder .buildTargetGroupBindingNetworking (targetPort , * tgSpec .HealthCheckConfig .Port , * backend . ServicePort , backendSGIDToken )
133
+ tgbNetworking := builder .buildTargetGroupBindingNetworking (targetPort , * tgSpec .HealthCheckConfig .Port , tgSpec . Protocol , backendSGIDToken )
133
134
134
135
multiClusterEnabled := builder .buildTargetGroupBindingMultiClusterFlag (tgProps )
135
136
@@ -175,14 +176,14 @@ func (builder *targetGroupBuilderImpl) buildTargetGroupBindingSpec(gw *gwv1.Gate
175
176
}
176
177
}
177
178
178
- func (builder * targetGroupBuilderImpl ) buildTargetGroupBindingNetworking (targetPort intstr.IntOrString , healthCheckPort intstr.IntOrString , svcPort corev1. ServicePort , backendSGIDToken core.StringToken ) * elbv2model.TargetGroupBindingNetworking {
179
+ func (builder * targetGroupBuilderImpl ) buildTargetGroupBindingNetworking (targetPort intstr.IntOrString , healthCheckPort intstr.IntOrString , tgProtocol elbv2model. Protocol , backendSGIDToken core.StringToken ) * elbv2model.TargetGroupBindingNetworking {
179
180
if backendSGIDToken == nil {
180
181
return nil
181
182
}
182
183
protocolTCP := elbv2api .NetworkingProtocolTCP
183
184
protocolUDP := elbv2api .NetworkingProtocolUDP
184
185
185
- udpSupported := svcPort . Protocol == corev1 .ProtocolUDP
186
+ udpSupported := tgProtocol == elbv2model .ProtocolUDP || tgProtocol == elbv2model . ProtocolTCP_UDP
186
187
187
188
if builder .disableRestrictedSGRules {
188
189
ports := []elbv2api.NetworkingPort {
@@ -282,7 +283,7 @@ func (builder *targetGroupBuilderImpl) buildTargetGroupSpec(gw *gwv1.Gateway, ro
282
283
return elbv2model.TargetGroupSpec {}, err
283
284
}
284
285
tgPort := builder .buildTargetGroupPort (targetType , * backend .ServicePort )
285
- name := builder .buildTargetGroupName (targetGroupProps , k8s .NamespacedName (gw ), route .GetRouteNamespacedName (), k8s .NamespacedName (backend .Service ), tgPort , targetType , tgProtocol , tgProtocolVersion )
286
+ name := builder .buildTargetGroupName (targetGroupProps , k8s .NamespacedName (gw ), route .GetRouteNamespacedName (), route . GetRouteKind (), k8s .NamespacedName (backend .Service ), tgPort , targetType , tgProtocol , tgProtocolVersion )
286
287
return elbv2model.TargetGroupSpec {
287
288
Name : name ,
288
289
TargetType : targetType ,
@@ -300,7 +301,7 @@ var invalidTargetGroupNamePattern = regexp.MustCompile("[[:^alnum:]]")
300
301
301
302
// buildTargetGroupName will calculate the targetGroup's name.
302
303
func (builder * targetGroupBuilderImpl ) buildTargetGroupName (targetGroupProps * elbv2gw.TargetGroupProps ,
303
- gwKey types.NamespacedName , routeKey types.NamespacedName , svcKey types.NamespacedName , tgPort int32 ,
304
+ gwKey types.NamespacedName , routeKey types.NamespacedName , routeKind routeutils. RouteKind , svcKey types.NamespacedName , tgPort int32 ,
304
305
targetType elbv2model.TargetType , tgProtocol elbv2model.Protocol , tgProtocolVersion * elbv2model.ProtocolVersion ) string {
305
306
306
307
if targetGroupProps != nil && targetGroupProps .TargetGroupName != nil {
@@ -313,6 +314,7 @@ func (builder *targetGroupBuilderImpl) buildTargetGroupName(targetGroupProps *el
313
314
_ , _ = uuidHash .Write ([]byte (gwKey .Name ))
314
315
_ , _ = uuidHash .Write ([]byte (routeKey .Namespace ))
315
316
_ , _ = uuidHash .Write ([]byte (routeKey .Name ))
317
+ _ , _ = uuidHash .Write ([]byte (routeKind ))
316
318
_ , _ = uuidHash .Write ([]byte (svcKey .Namespace ))
317
319
_ , _ = uuidHash .Write ([]byte (svcKey .Name ))
318
320
_ , _ = uuidHash .Write ([]byte (strconv .Itoa (int (tgPort ))))
@@ -660,8 +662,8 @@ func (builder *targetGroupBuilderImpl) convertMapToAttributes(attributeMap map[s
660
662
return convertedAttributes
661
663
}
662
664
663
- func (builder * targetGroupBuilderImpl ) buildTargetGroupResourceID (gwKey types.NamespacedName , svcKey types.NamespacedName , routeKey types.NamespacedName , port intstr.IntOrString ) string {
664
- return fmt .Sprintf ("%s/%s:%s-%s:%s-%s:%s" , gwKey .Namespace , gwKey .Name , routeKey .Namespace , routeKey .Name , svcKey .Namespace , svcKey .Name , port .String ())
665
+ func (builder * targetGroupBuilderImpl ) buildTargetGroupResourceID (gwKey types.NamespacedName , svcKey types.NamespacedName , routeKey types.NamespacedName , routeKind routeutils. RouteKind , port intstr.IntOrString ) string {
666
+ return fmt .Sprintf ("%s/%s:%s-%s:%s-%s-%s :%s" , gwKey .Namespace , gwKey .Name , routeKey .Namespace , routeKey .Name , routeKind , svcKey .Namespace , svcKey .Name , port .String ())
665
667
}
666
668
667
669
func (builder * targetGroupBuilderImpl ) buildTargetGroupBindingNodeSelector (tgProps * elbv2gw.TargetGroupProps , targetType elbv2model.TargetType ) * metav1.LabelSelector {
0 commit comments