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

Conversation

adleong
Copy link
Member

@adleong adleong commented Oct 31, 2023

When we do a GetProfile lookup for an unmeshed pod, we set the weightedAddr.ProtocolHint to an empty value &pb.ProtocolHint{} to indicate that the address is unmeshed and has no protocol hint. However, when the looked up port is in the default opaque list, we erroneously check if weightedAddr.ProtocolHint != nil to determine if we should attempt to get the inbound listen port for that pod. Since &pb.ProtocolHint{} != nil, we attempt to get the inbound listen port for the unmeshed pod. This results in an error, preventing any valid GetProfile responses from being returned.

We update the initialization logic for weightedAddr.ProtocolHint to only create a struct when a protocol hint is present and to leave it as nil if the pod is unmeshed.

We add a simple unit test for this behavior as well.

Signed-off-by: Alex Leong <alex@buoyant.io>
Signed-off-by: Alex Leong <alex@buoyant.io>
@adleong adleong requested a review from a team as a code owner October 31, 2023 19:42
@olix0r olix0r self-requested a review October 31, 2023 20:26
controller/api/destination/endpoint_translator.go Outdated Show resolved Hide resolved
controller/api/destination/server_test.go Outdated Show resolved Hide resolved
Signed-off-by: Alex Leong <alex@buoyant.io>
@@ -55,25 +55,6 @@ func (ept *endpointProfileTranslator) Update(address *watcher.Address) (bool, er
return false, fmt.Errorf("failed to create endpoint: %w", err)
}

// The protocol for an endpoint should only be updated if there is a pod,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of this protocol hinting logic is already implemented in createWeightedAddr and the endpoint that we get from createEndpoint already has the protocol hinting metadata set on it correctly. This code block is redundant.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this function unit tested? Shouldn't a test break somewhere if so?

controller/api/destination/server_test.go Outdated Show resolved Hide resolved
controller/api/destination/endpoint_translator.go Outdated Show resolved Hide resolved
controller/api/destination/endpoint_translator.go Outdated Show resolved Hide resolved
Signed-off-by: Alex Leong <alex@buoyant.io>
@olix0r olix0r changed the title Fix error for profile lookups on unmesehd pods with port in default opaque list Fix error for profile lookups on unmeshed pods with port in default opaque list Nov 1, 2023
Signed-off-by: Alex Leong <alex@buoyant.io>
@olix0r olix0r self-requested a review November 17, 2023 23:48
Signed-off-by: Alex Leong <alex@buoyant.io>
Copy link
Member

@alpeb alpeb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines 282 to 286
if err != nil {
log.Errorf("Failed to subscribe to profile by ip %q: %q", dest.GetPath(), err)
return err
}
return nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if err != nil {
log.Errorf("Failed to subscribe to profile by ip %q: %q", dest.GetPath(), err)
return err
}
return nil
if err != nil {
log.Errorf("Failed to subscribe to profile by ip %q: %q", dest.GetPath(), err)
}
return err

Comment on lines 290 to 294
if err != nil {
log.Errorf("Failed to subscribe to profile by name %q: %q", dest.GetPath(), err)
return err
}
return nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if err != nil {
log.Errorf("Failed to subscribe to profile by name %q: %q", dest.GetPath(), err)
return err
}
return nil
if err != nil {
log.Errorf("Failed to subscribe to profile by name %q: %q", dest.GetPath(), err)
}
return err

Signed-off-by: Alex Leong <alex@buoyant.io>
Signed-off-by: Alex Leong <alex@buoyant.io>
@adleong adleong merged commit a92d17d into main Dec 20, 2023
33 checks passed
@adleong adleong deleted the alex/unmeshed-and-opaque branch December 20, 2023 21:56
@adleong adleong mentioned this pull request Dec 20, 2023
adleong added a commit that referenced this pull request Dec 20, 2023
This edge release contains improvements to the logging and diagnostics of the
destination controller.

* Added a control plane metric to count errors talking to the Kubernetes API
  ([#11774])
* Fixed an issue causing spurious destination controller error messages for
  profile lookups on unmeshed pods with port in default opaque list ([#11550])

[#11774]: #11774
[#11550]: #11550

Signed-off-by: Alex Leong <alex@buoyant.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants