-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[feat gw-api]implement httproute matching and weighted target group #4241
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
Conversation
Hi @shuqz. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
return tgErr | ||
} | ||
actions := buildL4ListenerDefaultActions(targetGroup) // TODO: update this and weighted target group support | ||
albRules = append(albRules, ingress.Rule{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be best to not mingle the ingress
and gateway
packages. Would it be possible to take some time to refactor what we need out of the ingress package into a common package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i will take a look
pkg/gateway/model/utilities.go
Outdated
}) | ||
} | ||
|
||
type RulePrecedence struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: consider putting this into it's own file, as to not bloat the general utilities file.
pkg/gateway/model/utilities.go
Outdated
for _, route := range routes { | ||
routeNamespacedName := route.GetRouteNamespacedName().String() | ||
routeCreateTimestamp := getRouteCreateTimestamp(route) | ||
highestPrecedenceHostname := getHighestPrecedenceHostname(route.GetHostnames()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is interesting. Were you following a specific specification here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nvm, found it here. https://gateway-api.sigs.k8s.io/reference/spec/#httproute
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I need some clarification, because I only see these specific rules under the GRPC route.
https://gateway-api.sigs.k8s.io/reference/spec/#grpcroutespec
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
synced offline regarding this, added the missing piece in new commit
if pathType == gwv1.PathMatchPathPrefix { | ||
// the paths `/abc`, `/abc/`, and `/abc/def` would all match the prefix `/abc`, but the path `/abcd` would not. | ||
if pathValue == "/" { | ||
pathValue = "/*" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain why this is needed? I was checking against the Ingress implementation and we translate /
-> /
without adding the wildcard.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i was thinking, when pathType and value is not specified, it will be automatically assigned as prefix and /. and in this case, we should pass /* to ALB to present that this allows all path.
// +optional
// +kubebuilder:default={type: "PathPrefix", value: "/"}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this what you're referring to?
// If no matches are specified, the default is a prefix
// path match on "/", which has the effect of matching every
// HTTP request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
synced offline
}) | ||
} | ||
|
||
func getHostnameListPrecedenceOrder(hostnameOne, hostnameTwo []string) int { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: adding a comment stating that the behavior is to NOT tiebreak when lists are not equal length but have the same elements, e.g
routeA:
hostname:
- "test.example.com" -> highest
- "test.a.com"
- "*.a.com"
routeB:
hostname:
- "test.example.com"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah i have a comment regarding this before return 0 at the end, but i can add a general comment for this function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT : func getHostnameListPrecedenceOrder(hostnameListOne, hostnameListTwo []string)
/lgtm |
|
||
for _, route := range routes { | ||
routeNamespacedName := route.GetRouteNamespacedName().String() | ||
routeCreateTimestamp := getRouteCreateTimestamp(route) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT : Add this getRouteCreateTimestamp
as part of routeMetadataDescriptor
interface as its part of metadata of the routes.
type routeMetadataDescriptor interface {
GetRouteNamespacedName() types.NamespacedName
GetRouteKind() RouteKind
GetHostnames() []gwv1.Hostname
GetParentRefs() []gwv1.ParentReference
GetRawRoute() interface{}
GetBackendRefs() []gwv1.BackendRef
GetRouteGeneration() int64
GetRouteCreateTimestamp() time.Time // Add this method
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea
// this is only for L7 ALB | ||
func (l listenerBuilderImpl) buildListenerRules(stack core.Stack, ls *elbv2model.Listener, lb *elbv2model.LoadBalancer, securityGroups securityGroupOutput, gw *gwv1.Gateway, port int32, lbCfg elbv2gw.LoadBalancerConfiguration, routes map[int32][]routeutils.RouteDescriptor) error { | ||
// sort all rules based on precedence | ||
routesWithPrecedenceOrder := routeutils.SortAllRulesByPrecedence(routes[port]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: renameroutesWithPrecedenceOrder
to rulesWithPrecedenceOrder
rule := ruleWithPrecedence.Rule | ||
var hostnamesStringList []string | ||
// add hostname to condition | ||
if hostnames := route.GetHostnames(); len(hostnames) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have this info already in ruleWithPrecedence
. No need to create hostnamesStringList again from route.
Replace this with hostnamesStringList :=ruleWithPrecedence.Hostnames
synced with shraddhabang we will defer validation check to API directly, resolving all validation related comments. |
add weighted target group support and factor previous commit address feedbacks and fix bug in prefix path build
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: shuqz, zac-nixon The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/lgtm |
Description
Checklist
README.md
, or thedocs
directory)result:
BONUS POINTS checklist: complete for good vibes and maybe prizes?! 🤯