Skip to content

Commit

Permalink
Fix GetProfiles error when address is opaque and unmeshed (#11556)
Browse files Browse the repository at this point in the history
When we do a GetProfile lookup for an opaque port on an unmeshed pod,
we attempt to look up the inbound listen port of that pod's proxy. Since
that pod has no proxy, this fails and we return an error to the GetProfile
API call. This causes the proxy to fail to be able to resolve the profile and
be unable to route the traffic.

We revert to the previous behavior of only logging when we cannot look
up the inbound listen port instead of returning an error.

Signed-off-by: Alex Leong <[email protected]>
  • Loading branch information
adleong authored Nov 2, 2023
1 parent 75159cb commit 8cf3863
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
10 changes: 5 additions & 5 deletions controller/api/destination/endpoint_profile_translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ func (ept *endpointProfileTranslator) Update(address *watcher.Address) (bool, er
} else if endpoint.ProtocolHint.OpaqueTransport == nil {
port, err := getInboundPort(&address.Pod.Spec)
if err != nil {
return false, err
}

endpoint.ProtocolHint.OpaqueTransport = &pb.ProtocolHint_OpaqueTransport{
InboundPort: port,
ept.log.Error(err)
} else {
endpoint.ProtocolHint.OpaqueTransport = &pb.ProtocolHint_OpaqueTransport{
InboundPort: port,
}
}
}

Expand Down
17 changes: 17 additions & 0 deletions controller/api/destination/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,23 @@ func TestGetProfiles(t *testing.T) {
}
})

t.Run("Return profile with no opaque transport when pod does not have label and port is opaque", func(t *testing.T) {
server := makeServer(t)
defer server.clusterStore.UnregisterGauges()

// port 3306 is in the default opaque port list
stream := profileStream(t, server, podIP2, 3306, "")
defer stream.Cancel()
profile := assertSingleProfile(t, stream.Updates())
if profile.Endpoint == nil {
t.Fatalf("Expected response to have endpoint field")
}

if profile.Endpoint.GetProtocolHint().GetOpaqueTransport() != nil {
t.Fatalf("Expected no opaque transport but found one")
}
})

t.Run("Return profile with no protocol hint when pod does not have label", func(t *testing.T) {
server := makeServer(t)
defer server.clusterStore.UnregisterGauges()
Expand Down

0 comments on commit 8cf3863

Please sign in to comment.