Hybrid Gateway conformance: enable HTTPRouteMatching test#3577
Hybrid Gateway conformance: enable HTTPRouteMatching test#3577tao12345666333 wants to merge 2 commits intomainfrom
Conversation
449aaf6 to
578ed85
Compare
…e HTTPRouteMatching conformance for hybrid Signed-off-by: Jintao Zhang <zhangjintao9020@gmail.com>
578ed85 to
05927d4
Compare
| // Build the KongRoute resource. | ||
| routePtr, err := kongroute.RouteForRule(ctx, logger, c.Client, c.route, rule, &pRef, cp, serviceName, hostnames) | ||
| // Build one KongRoute per match in the rule. | ||
| routes, err := kongroute.RoutesForRule(ctx, logger, c.Client, c.route, rule, &pRef, cp, serviceName, hostnames) |
There was a problem hiding this comment.
Could you please explain why one route is required for each rule?
There was a problem hiding this comment.
Done. Added explanations in the RoutesForRule godoc and at the call site
The key reason: Gateway API specifies matches within a rule are ORed, but Kong combines all matchers on a single route with AND. Splitting to one route per match preserves the OR semantics, which is required by conformance tests like HTTPRouteMatching.
| return nil, err | ||
| // Add to result slice. | ||
| routeCopy := newRoute | ||
| kongRoutes = append(kongRoutes, &routeCopy) |
There was a problem hiding this comment.
Why do we need a copy of the route built by the builder?
There was a problem hiding this comment.
Good point. Replaced with newRoute.DeepCopy() to express the intent more clearly. Each loop iteration should yield an independent KongRoute object.
Signed-off-by: Jintao Zhang <zhangjintao9020@gmail.com>
0f53c04 to
26af385
Compare
What this PR does / why we need it:
Which issue this PR fixes
Fixes #3442
Special notes for your reviewer:
PR Readiness Checklist:
Complete these before marking the PR as
ready to review:CHANGELOG.mdrelease notes have been updated to reflect significant changes