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

feat(rules): support Labels with SectionName in ResolveTargetRef function #12743

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

lobkovilya
Copy link
Contributor

Motivation

It's a valid use case to use both Labels and SectionName in to[].targetRef.

Implementation information

  • refactored ResolveTargetRef method to avoid duplicating logic
  • added unit tests

@lobkovilya lobkovilya requested a review from a team as a code owner February 4, 2025 09:09
@lobkovilya lobkovilya requested review from slonka and lukidzi February 4, 2025 09:09
@lobkovilya lobkovilya changed the title feat(policies): ResolveTargetRef to support labels with sectionName feat(policies): support Labels with SectionName in ResolveTargetRef function Feb 4, 2025
@lobkovilya lobkovilya changed the title feat(policies): support Labels with SectionName in ResolveTargetRef function feat(rules): support Labels with SectionName in ResolveTargetRef function Feb 4, 2025
Copy link
Contributor

github-actions bot commented Feb 4, 2025

Reviewer Checklist

🔍 Each of these sections need to be checked by the reviewer of the PR 🔍:
If something doesn't apply please check the box and add a justification if the reason is non obvious.

  • Is the PR title satisfactory? Is this part of a larger feature and should be grouped using > Changelog?
  • PR description is clear and complete. It Links to relevant issue as well as docs and UI issues
  • This will not break child repos: it doesn't hardcode values (.e.g "kumahq" as an image registry)
  • IPv6 is taken into account (.e.g: no string concatenation of host port)
  • Tests (Unit test, E2E tests, manual test on universal and k8s)
    • Don't forget ci/ labels to run additional/fewer tests
  • Does this contain a change that needs to be notified to users? In this case, UPGRADE.md should be updated.
  • Does it need to be backported according to the backporting policy? (this GH action will add "backport" label based on these file globs, if you want to prevent it from adding the "backport" label use no-backport-autolabel label)

slonka
slonka previously approved these changes Feb 4, 2025
Copy link
Contributor

@slonka slonka left a comment

Choose a reason for hiding this comment

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

Just Qs

@@ -136,7 +163,7 @@ func parseService(host string) (string, string, uint32, error) {
case 3:
// service less service names have no port, so we just put the reserved
// one here to note that this service is actually
port = mesh_proto.TCPPortReserved
port = 0
Copy link
Contributor

Choose a reason for hiding this comment

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

this seems unrelated 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The function parseService was copied from here outbound_converter.go. When a port is not specified, i.e. backend_kuma-demo_svc it returned reserved port value 49151.

I don't really know why we need this reserved value in outbound_converter.go, but in resolvedtargetref.go I didn't want to introduce extra handling of special values especially when value 0 works perfectly fine for this case. Otherwise, I'd have to add here something like

- if q.port == 0 && q.sectionName == "" {
+ if (q.port == 0 || q.port == mesh_proto.TCPPortReserved) && q.sectionName == "" {

Copy link
Contributor

Choose a reason for hiding this comment

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

should we somehow document that it was copied? or maybe we should make it DRY?

Signed-off-by: Ilya Lobkov <[email protected]>
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.

2 participants