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 error for profile lookups on unmeshed pods with port in default opaque list #11550

Merged
merged 8 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func (ept *endpointProfileTranslator) Update(address *watcher.Address) (bool, er
} else if endpoint.ProtocolHint.OpaqueTransport == nil {
port, err := getInboundPort(&address.Pod.Spec)
if err != nil {
ept.log.Error(err)
return false, err
}

Expand Down
2 changes: 1 addition & 1 deletion controller/api/destination/endpoint_translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,8 +494,8 @@ func createWeightedAddr(address watcher.Address, opaquePorts map[uint32]struct{}
// If the pod is controlled by any Linkerd control plane, then it can be
// hinted that this destination knows H2 (and handles our orig-proto
// translation)
weightedAddr.ProtocolHint = &pb.ProtocolHint{}
if controllerNSLabel != "" && !isSkippedInboundPort {
weightedAddr.ProtocolHint = &pb.ProtocolHint{}
adleong marked this conversation as resolved.
Show resolved Hide resolved
// If address is set as opaque by a Server, or its port is set as
// opaque by annotation or default value, then hint its proxy's
// inbound port, and set the hinted protocol to Opaque, so that the
Expand Down
22 changes: 19 additions & 3 deletions controller/api/destination/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,22 @@ func TestGetProfiles(t *testing.T) {
}
})

t.Run("Return profile with no protocol hint for default opaque port when pod is unmeshed", func(t *testing.T) {
server := makeServer(t)
defer server.clusterStore.UnregisterGauges()

// 3306 is in the default opaque 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().GetProtocol() != nil || profile.Endpoint.GetProtocolHint().GetOpaqueTransport() != nil {
t.Fatalf("Expected no protocol hint but found one")
}
adleong marked this conversation as resolved.
Show resolved Hide resolved
})

t.Run("Return non-opaque protocol profile when using cluster IP and opaque protocol port", func(t *testing.T) {
server := makeServer(t)
defer server.clusterStore.UnregisterGauges()
Expand Down Expand Up @@ -480,7 +496,7 @@ func TestGetProfiles(t *testing.T) {
if profile.Endpoint.ProtocolHint == nil {
t.Fatalf("Expected protocol hint but found none")
}
if profile.Endpoint.ProtocolHint.GetOpaqueTransport().GetInboundPort() != 4143 {
if profile.Endpoint.GetProtocolHint().GetOpaqueTransport().GetInboundPort() != 4143 {
t.Fatalf("Expected pod to support opaque traffic on port 4143")
}
if profile.Endpoint.Addr.String() != epAddr.String() {
Expand Down Expand Up @@ -535,10 +551,10 @@ func TestGetProfiles(t *testing.T) {
if !profile.OpaqueProtocol {
t.Fatalf("Expected port %d to be an opaque protocol, but it was not", 80)
}
if profile.Endpoint.ProtocolHint == nil {
if profile.Endpoint.GetProtocolHint() == nil {
t.Fatalf("Expected protocol hint but found none")
}
if profile.Endpoint.ProtocolHint.GetOpaqueTransport().GetInboundPort() != 4143 {
if profile.Endpoint.GetProtocolHint().GetOpaqueTransport().GetInboundPort() != 4143 {
t.Fatalf("Expected pod to support opaque traffic on port 4143")
}
})
Expand Down
Loading