Skip to content

Commit fe42367

Browse files
committed
fix getting service backends in dual-stack clusters (#2323)
1 parent 33e6e41 commit fe42367

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pkg/controller/endpoint.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,9 @@ func getServicePortBackends(endpoints *v1.Endpoints, pods []*v1.Pod, servicePort
237237

238238
for _, address := range subset.Addresses {
239239
if address.TargetRef == nil || address.TargetRef.Kind != "Pod" {
240-
backends = append(backends, util.JoinHostPort(address.IP, targetPort))
240+
if util.CheckProtocol(address.IP) == protocol {
241+
backends = append(backends, util.JoinHostPort(address.IP, targetPort))
242+
}
241243
continue
242244
}
243245

@@ -257,7 +259,7 @@ func getServicePortBackends(endpoints *v1.Endpoints, pods []*v1.Pod, servicePort
257259
break
258260
}
259261
}
260-
if ip == "" {
262+
if ip == "" && util.CheckProtocol(address.IP) == protocol {
261263
ip = address.IP
262264
}
263265
if ip != "" {

0 commit comments

Comments
 (0)