diff --git a/controller/api/destination/endpoint_profile_translator.go b/controller/api/destination/endpoint_profile_translator.go index 85c7f45bf7f33..8ca312b1563d8 100644 --- a/controller/api/destination/endpoint_profile_translator.go +++ b/controller/api/destination/endpoint_profile_translator.go @@ -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, + } } } diff --git a/controller/api/destination/server_test.go b/controller/api/destination/server_test.go index e169b4b102106..d83555a3cd923 100644 --- a/controller/api/destination/server_test.go +++ b/controller/api/destination/server_test.go @@ -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()