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 weighted route #2187

Merged
merged 6 commits into from
Nov 14, 2023
Merged

Fix weighted route #2187

merged 6 commits into from
Nov 14, 2023

Conversation

zhaohuabing
Copy link
Member

@zhaohuabing zhaohuabing commented Nov 14, 2023

fix #2170

Envoy requires a distinct region to be set for each LocalityLbEndpoints. If we don't do this, Envoy will merge all LocalityLbEndpoints into one. In this PR, the name of the backendRef is used as a pseudo region name to avoid this issue.

HTTPRoute

apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: http-headers
  namespace: default
spec:
  hostnames:
  - backends.example
  parentRefs:
  - group: gateway.networking.k8s.io
    kind: Gateway
    name: eg
  rules:
  - backendRefs:
    - group: ""
      kind: Service
      name: backend
      port: 3000
      weight: 8
    - group: ""
      kind: Service
      name: backend-2
      port: 2000
      weight: 2
    matches:
    - path:
        type: PathPrefix
        value: /

EDS

"dynamicEndpointConfigs": [
        {
          "endpointConfig": {
            "@type": "type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment",
            "clusterName": "httproute/default/http-headers/rule/0",
            "endpoints": [
              {
                "lbEndpoints": [
                  {
                    "endpoint": {
                      "address": {
                        "socketAddress": {
                          "address": "10.244.0.8",
                          "portValue": 3000
                        }
                      },
                      "healthCheckConfig": {}
                    },
                    "healthStatus": "HEALTHY",
                    "loadBalancingWeight": 1
                  }
                ],
                "loadBalancingWeight": 8,
                "locality": {
                  "region": "httproute/default/http-headers/rule/0/backend/0"
                }
              },
              {
                "lbEndpoints": [
                  {
                    "endpoint": {
                      "address": {
                        "socketAddress": {
                          "address": "10.244.0.10",
                          "portValue": 2000
                        }
                      },
                      "healthCheckConfig": {}
                    },
                    "healthStatus": "HEALTHY",
                    "loadBalancingWeight": 1
                  }
                ],
                "loadBalancingWeight": 2,
                "locality": {
                  "region": "httproute/default/http-headers/rule/0/backend/1"
                }
              }
            ],
            "policy": {
              "overprovisioningFactor": 140
            }
          }
        }
      ],

@zhaohuabing zhaohuabing requested a review from a team as a code owner November 14, 2023 14:05
zirain
zirain previously approved these changes Nov 14, 2023
arkodg
arkodg previously approved these changes Nov 14, 2023
Copy link
Contributor

@arkodg arkodg left a comment

Choose a reason for hiding this comment

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

LGTM thanks for solving this one !

@arkodg
Copy link
Contributor

arkodg commented Nov 14, 2023

gen-check is failing , can you run make testdata

@zhaohuabing zhaohuabing dismissed stale reviews from arkodg and zirain via c3f433d November 14, 2023 16:21
@zhaohuabing
Copy link
Member Author

@arkodg how about changing the locality name to "httproute/default/http-headers/rule/0/backend/0? backend is clearer than setting.

Copy link

codecov bot commented Nov 14, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (f92da90) 64.17% compared to head (7fa2aa0) 64.22%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2187      +/-   ##
==========================================
+ Coverage   64.17%   64.22%   +0.05%     
==========================================
  Files         107      107              
  Lines       14922    14924       +2     
==========================================
+ Hits         9576     9585       +9     
+ Misses       4770     4764       -6     
+ Partials      576      575       -1     

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

Signed-off-by: huabing zhao <zhaohuabing@gmail.com>
Signed-off-by: huabing zhao <zhaohuabing@gmail.com>
This reverts commit e051644.

Signed-off-by: huabing zhao <zhaohuabing@gmail.com>
Signed-off-by: huabing zhao <zhaohuabing@gmail.com>
Signed-off-by: huabing zhao <zhaohuabing@gmail.com>
Signed-off-by: huabing zhao <zhaohuabing@gmail.com>
@arkodg arkodg merged commit 6ba9ea4 into envoyproxy:main Nov 14, 2023
18 checks passed
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.

Weighted BackendRefs not showing expected outcome
3 participants