Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GetProfiles error when address is opaque and unmeshed #11556

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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