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: btlsp section name doesn't support port name #4784

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

zhaohuabing
Copy link
Member

@zhaohuabing zhaohuabing commented Nov 26, 2024

Fixes #4769

This PR allows using port name as the sectionName for the targetRefs of the BackendTLSPolicy.

The support for port number has been retained because:

  • Port names are optional for Kubernetes services
  • To keep align with the Backend API, which doesn't have a name for its port

Release Notes: Yes

@zhaohuabing zhaohuabing requested a review from a team as a code owner November 26, 2024 07:39
@zhaohuabing zhaohuabing marked this pull request as draft November 26, 2024 07:39
@zhaohuabing zhaohuabing changed the title fix btlsp section name fix btlsp section name doesn't support service name Nov 26, 2024
@zhaohuabing zhaohuabing changed the title fix btlsp section name doesn't support service name fix: btlsp section name doesn't support port name Nov 26, 2024
Copy link

codecov bot commented Nov 26, 2024

Codecov Report

Attention: Patch coverage is 62.06897% with 11 lines in your changes missing coverage. Please review.

Project coverage is 65.59%. Comparing base (17e932c) to head (587da5d).

Files with missing lines Patch % Lines
internal/gatewayapi/backendtlspolicy.go 75.00% 4 Missing and 2 partials ⚠️
internal/gatewayapi/resource/resource.go 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4784      +/-   ##
==========================================
- Coverage   65.59%   65.59%   -0.01%     
==========================================
  Files         211      211              
  Lines       32001    32024      +23     
==========================================
+ Hits        20992    21005      +13     
- Misses       9767     9775       +8     
- Partials     1242     1244       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zhaohuabing zhaohuabing marked this pull request as ready for review November 26, 2024 08:10
Signed-off-by: Huabing Zhao <[email protected]>
Signed-off-by: Huabing Zhao <[email protected]>
Signed-off-by: Huabing Zhao <[email protected]>
target := getTargetBackendReference(backendRef)
for _, policy := range policies {
if backendTLSTargetMatched(*policy, target, backendNamespace) {
return policy
}
}

// SectionName can be port name for Kubernetes Service
target = getTargetBackendReferenceWithPortName(backendRef, backendNamespace, resources)
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need another new function
isnt there logic already for this in

// if section name is not set, then it targets the entire backend
?

Copy link
Member Author

Choose a reason for hiding this comment

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

This function uses port name instead of port number as sectionName to match policy.

Copy link
Contributor

Choose a reason for hiding this comment

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

lets support port number - section name matching for Backend and only port name - section name matching for Service, this ensures the user config can be safely migrated and tested in other controllers

Signed-off-by: Huabing Zhao <[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
2 participants