Skip to content

Commit 1ab955e

Browse files
authored
fix(destination): properly discover native sidecar ports (#14814
(Extracted from #14566) The `Get` API wasn't surfacing ports marked as opaque in Servers, when: 1. ports belonged to a native sidecar (inside an init container) 2. port was referred to by name Also changed a test fixture to use port name instead of number in order to test this issue.
1 parent eded8a4 commit 1ab955e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

controller/api/destination/test_util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ spec:
631631
podSelector:
632632
matchLabels:
633633
app: native
634-
port: 80
634+
port: http
635635
proxyProtocol: opaque`,
636636
}
637637

controller/api/destination/watcher/endpoints_watcher.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,7 +1363,7 @@ func (pp *portPublisher) isAddressSelected(address Address, server *v1beta3.Serv
13631363
return true
13641364
}
13651365
case intstr.String:
1366-
for _, c := range address.Pod.Spec.Containers {
1366+
for _, c := range append(address.Pod.Spec.InitContainers, address.Pod.Spec.Containers...) {
13671367
for _, p := range c.Ports {
13681368
if p.ContainerPort == int32(address.Port) && p.Name == server.Spec.Port.StrVal {
13691369
return true
@@ -1550,7 +1550,7 @@ func SetToServerProtocol(k8sAPI *k8s.API, address *Address, log *logging.Entry)
15501550
portMatch = true
15511551
}
15521552
case intstr.String:
1553-
for _, c := range address.Pod.Spec.Containers {
1553+
for _, c := range append(address.Pod.Spec.InitContainers, address.Pod.Spec.Containers...) {
15541554
for _, p := range c.Ports {
15551555
if (p.ContainerPort == int32(address.Port) || p.HostPort == int32(address.Port)) &&
15561556
p.Name == server.Spec.Port.StrVal {

0 commit comments

Comments
 (0)