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

Using backendTrafficPolicies to patch route resources may lead to unexpected results. #2366

Closed
tmsnan opened this issue Dec 26, 2023 · 0 comments · Fixed by #2369
Closed
Assignees
Labels

Comments

@tmsnan
Copy link
Contributor

tmsnan commented Dec 26, 2023

Description:

Using backendTrafficPolicies to patch httproute resources may lead to unexpected results.

For example:

- apiVersion: gateway.networking.k8s.io/v1
  kind: Gateway
  metadata:
    namespace: envoy-gateway
    name: gateway-1
  spec:
    gatewayClassName: envoy-gateway-class
    listeners:
    - name: http
      protocol: HTTP
      port: 80
      allowedRoutes:
        namespaces:
          from: All
httpRoutes:
- apiVersion: gateway.networking.k8s.io/v1
  kind: HTTPRoute
  metadata:
    namespace: default
    name: httproute-1
  spec:
    hostnames:
    - gateway.envoyproxy.io
    parentRefs:
    - namespace: envoy-gateway
      name: gateway-1
      sectionName: http
    rules:
    - matches:
      - path:
          value: "/"
      backendRefs:
      - name: service-1
        port: 8080
- apiVersion: gateway.networking.k8s.io/v1
  kind: HTTPRoute
  metadata:
    namespace: default
    name: httproute-1-mirror
  spec:
    hostnames:
    - gateway.envoyproxy.io
    parentRefs:
    - namespace: envoy-gateway
      name: gateway-1
      sectionName: http
    rules:
    - matches:
      - path:
          value: "/mirror"
      backendRefs:
      - name: service-1
        port: 8080
- apiVersion: gateway.envoyproxy.io/v1alpha1
  kind: BackendTrafficPolicy
  metadata:
    namespace: default
    name: policy-for-route
  spec:
    targetRef:
      group: gateway.networking.k8s.io
      kind: HTTPRoute
      name: httproute-1
      namespace: default
    rateLimit:
      type: Global
      global:
        rules:
        - clientSelectors:
          - sourceCIDR:
              type: "Distinct"
              value: 192.168.0.0/16
          limit:
            requests: 20
            unit: Hour

backendTrafficPolicies will be patched to httproute-1 and httproute-1-mirror

Reason:

return fmt.Sprintf("%s/%s/%s", strings.ToLower(string(GetRouteType(route))), route.GetNamespace(), route.GetName())

if strings.HasPrefix(r.Name, prefix) {

Maybe add / to the prefix %s/%s/%s/

@tmsnan tmsnan added the triage label Dec 26, 2023
@tmsnan tmsnan changed the title Using backendTrafficPolicies to patch httproute resources may lead to unexpected results. Using backendTrafficPolicies to patch route resources may lead to unexpected results. Dec 26, 2023
@zhaohuabing zhaohuabing self-assigned this Dec 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants