@@ -536,7 +536,7 @@ func (n *NGINXController) getStreamServices(configmapName string, proto apiv1.Pr
536
536
sp := svc .Spec .Ports [i ]
537
537
if sp .Name == svcPort {
538
538
if sp .Protocol == proto {
539
- endps = getEndpointsFromSlices (svc , & sp , proto , zone , n .store .GetServiceEndpointsSlices )
539
+ endps = getEndpointsFromSlices (svc , & sp , proto , zone , ReadyEndpoints , n .store .GetServiceEndpointsSlices )
540
540
break
541
541
}
542
542
}
@@ -548,7 +548,7 @@ func (n *NGINXController) getStreamServices(configmapName string, proto apiv1.Pr
548
548
//nolint:gosec // Ignore G109 error
549
549
if sp .Port == int32 (targetPort ) {
550
550
if sp .Protocol == proto {
551
- endps = getEndpointsFromSlices (svc , & sp , proto , zone , n .store .GetServiceEndpointsSlices )
551
+ endps = getEndpointsFromSlices (svc , & sp , proto , zone , ReadyEndpoints , n .store .GetServiceEndpointsSlices )
552
552
break
553
553
}
554
554
}
@@ -605,7 +605,7 @@ func (n *NGINXController) getDefaultUpstream() *ingress.Backend {
605
605
} else {
606
606
zone = emptyZone
607
607
}
608
- endps := getEndpointsFromSlices (svc , & svc .Spec .Ports [0 ], apiv1 .ProtocolTCP , zone , n .store .GetServiceEndpointsSlices )
608
+ endps := getEndpointsFromSlices (svc , & svc .Spec .Ports [0 ], apiv1 .ProtocolTCP , zone , ReadyEndpoints , n .store .GetServiceEndpointsSlices )
609
609
if len (endps ) == 0 {
610
610
klog .Warningf ("Service %q does not have any active Endpoint" , svcKey )
611
611
endps = []ingress.Endpoint {n .DefaultEndpoint ()}
@@ -940,7 +940,7 @@ func (n *NGINXController) getBackendServers(ingresses []*ingress.Ingress) ([]*in
940
940
} else {
941
941
zone = emptyZone
942
942
}
943
- endps := getEndpointsFromSlices (location .DefaultBackend , & sp , apiv1 .ProtocolTCP , zone , n .store .GetServiceEndpointsSlices )
943
+ endps := getEndpointsFromSlices (location .DefaultBackend , & sp , apiv1 .ProtocolTCP , zone , ReadyEndpoints , n .store .GetServiceEndpointsSlices )
944
944
// custom backend is valid only if contains at least one endpoint
945
945
if len (endps ) > 0 {
946
946
name := fmt .Sprintf ("custom-default-backend-%v-%v" , location .DefaultBackend .GetNamespace (), location .DefaultBackend .GetName ())
@@ -1050,7 +1050,7 @@ func (n *NGINXController) createUpstreams(data []*ingress.Ingress, du *ingress.B
1050
1050
1051
1051
if len (upstreams [defBackend ].Endpoints ) == 0 {
1052
1052
_ , port := upstreamServiceNameAndPort (ing .Spec .DefaultBackend .Service )
1053
- endps , err := n .serviceEndpoints (svcKey , port .String ())
1053
+ endps , err := n .serviceEndpoints (svcKey , port .String (), ReadyEndpoints )
1054
1054
upstreams [defBackend ].Endpoints = append (upstreams [defBackend ].Endpoints , endps ... )
1055
1055
if err != nil {
1056
1056
klog .Warningf ("Error creating upstream %q: %v" , defBackend , err )
@@ -1115,7 +1115,8 @@ func (n *NGINXController) createUpstreams(data []*ingress.Ingress, du *ingress.B
1115
1115
1116
1116
if len (upstreams [name ].Endpoints ) == 0 {
1117
1117
_ , port := upstreamServiceNameAndPort (path .Backend .Service )
1118
- endp , err := n .serviceEndpoints (svcKey , port .String ())
1118
+ endp , err := n .serviceEndpoints (svcKey , port .String (), ReadyEndpoints )
1119
+
1119
1120
if err != nil {
1120
1121
klog .Warningf ("Error obtaining Endpoints for Service %q: %v" , svcKey , err )
1121
1122
n .metricCollector .IncOrphanIngress (ing .Namespace , ing .Name , orphanMetricLabelNoService )
@@ -1184,7 +1185,7 @@ func (n *NGINXController) getServiceClusterEndpoint(svcKey string, backend *netw
1184
1185
}
1185
1186
1186
1187
// serviceEndpoints returns the upstream servers (Endpoints) associated with a Service.
1187
- func (n * NGINXController ) serviceEndpoints (svcKey , backendPort string ) ([]ingress.Endpoint , error ) {
1188
+ func (n * NGINXController ) serviceEndpoints (svcKey , backendPort string , epSelectionMode EndpointSelectionMode ) ([]ingress.Endpoint , error ) {
1188
1189
var upstreams []ingress.Endpoint
1189
1190
1190
1191
svc , err := n .store .GetService (svcKey )
@@ -1205,7 +1206,7 @@ func (n *NGINXController) serviceEndpoints(svcKey, backendPort string) ([]ingres
1205
1206
return upstreams , nil
1206
1207
}
1207
1208
servicePort := externalNamePorts (backendPort , svc )
1208
- endps := getEndpointsFromSlices (svc , servicePort , apiv1 .ProtocolTCP , zone , n .store .GetServiceEndpointsSlices )
1209
+ endps := getEndpointsFromSlices (svc , servicePort , apiv1 .ProtocolTCP , zone , epSelectionMode , n .store .GetServiceEndpointsSlices )
1209
1210
if len (endps ) == 0 {
1210
1211
klog .Warningf ("Service %q does not have any active Endpoint." , svcKey )
1211
1212
return upstreams , nil
@@ -1221,7 +1222,7 @@ func (n *NGINXController) serviceEndpoints(svcKey, backendPort string) ([]ingres
1221
1222
if strconv .Itoa (int (servicePort .Port )) == backendPort ||
1222
1223
servicePort .TargetPort .String () == backendPort ||
1223
1224
servicePort .Name == backendPort {
1224
- endps := getEndpointsFromSlices (svc , & servicePort , apiv1 .ProtocolTCP , zone , n .store .GetServiceEndpointsSlices )
1225
+ endps := getEndpointsFromSlices (svc , & servicePort , apiv1 .ProtocolTCP , zone , epSelectionMode , n .store .GetServiceEndpointsSlices )
1225
1226
if len (endps ) == 0 {
1226
1227
klog .Warningf ("Service %q does not have any active Endpoint." , svcKey )
1227
1228
}
0 commit comments