[Improvement]: Load balance across all targets when upstream.main/sandbox uses ref to a multi-target upstream definition
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 55/100
Línea de trabajo
Start in gateway/gateway-controller/pkg/transform/restapi.go at resolveUpstreamURL and the main or sandbox cluster construction around line 676; compare how upstream definitions keep all targets in lines 295-347 and in gateway/gateway-controller/pkg/xds/translator.go around line 649. Trace how the referenced definition's cluster is selected, then check the Envoy route configuration. Done when main and sandbox refs route across every target using its weight, without requiring dynamic-endpoint.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Please select the area the issue is related to
Gateway
Please select the aspect the issue is related to
Aspect/API (API backends, definitions, contracts, interfaces, OpenAPI)
Suggested Improvement
Current limitation
When upstream.main or upstream.sandbox references an upstream definition with ref, the gateway uses only the first target in that definition and ignores the rest. resolveUpstreamURL returns def.Upstreams[0].Url (gateway/gateway-controller/pkg/transform/restapi.go:781), and the main or sandbox cluster is built with that single endpoint (restapi.go:676).
Nothing tells the user. The deployment succeeds, and an API that lists three backends quietly sends all its traffic to the first one. The only hint is a sentence in the weight field's description in the spec. The obvious reading of a definition with several weighted targets is that the API's traffic is balanced across them.
Today, balancing across targets only works if the user also attaches the dynamic-endpoint policy pointing at the same definition. That's undocumented and not what a user would expect to need.
The gateway already builds a cluster for every upstream definition that keeps all its targets and weights (restapi.go:295-347, gateway/gateway-controller/pkg/xds/translator.go:649). The main and sandbox routes just don't use it.
Reproduced on a running gateway built from main at 9ceea25b8, with two hashicorp/http-echo backends that reply backend-a and backend-b:
apiVersion: gateway.api-platform.wso2.com/v1
kind: RestApi
metadata:
name: ref-only
spec:
displayName: ref-only
version: v1.0
context: /ref-only/v1.0
upstreamDefinitions:
- name: pool
upstreams:
- url: http://backend-a:5000
weight: 50
- url: http://backend-b:5000
weight: 50
upstream:
main:
ref: pool
operations:
- method: GET
path: /echo
- The deployment succeeds (201) with no warning.
- Of 400 requests to
/ref-only/v1.0/echo, all 400 went tobackend-aand none tobackend-b. - In Envoy's
/config_dump, the route uses a main cluster that contains onlybackend-a. The definition's own cluster (upstream_RestApi_<id>_pool) exists with both endpoints weighted 50/50, but nothing routes to it. - The same definition behind the
dynamic-endpointpolicy splits 200/200, so the multi-target cluster itself works.
Suggested improvement
When upstream.main or upstream.sandbox references a definition, route to that definition's own multi-target cluster instead of building a separate single-endpoint cluster from its first URL. The API then load-balances across all targets with their weights, with no extra policy needed.
If that isn't possible yet, at least make the behaviour visible:
- Reject at deploy time a
refto a definition with more than one target, or return a deployment warning. - Document the limitation on
upstream.ref, not only onweight.
Related Issues
#4176
- Lenguaje dominante
- Go
- Estrellas
- 85
- Forks
- 137
- Merge medio
- 1 d 12 h
- PR fusionados (30 d)
- 247
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Sin guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de wso2/api-platform
-
Area/DeveloperPortal Aspect/UI Severity/Minor Type/Bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
wso2/api-platform#4369 ·
Los mantenedores suelen responder en 1 día
-
[Bug]: host-rewrite policy documentation lists fewer allowed host characters than the policy acceptsAbiertoArea/Policies Aspect/Other Severity/Trivial Type/Bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 91/100
wso2/api-platform#4355 ·
Los mantenedores suelen responder en 1 día
-
Area/Gateway Aspect/API Severity/Minor Type/Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
wso2/api-platform#4348 ·
Los mantenedores suelen responder en 1 día
-
Aspect/AI Aspect/API. Severity/Major
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
wso2/api-platform#4343 ·
Los mantenedores suelen responder en 1 día
-
[Bug]: content-length-guardrail policy accepts a non-string streamingJsonPath at API creationAbiertoArea/Policies Aspect/Configuration Severity/Minor Type/Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
wso2/api-platform#4330 ·
Los mantenedores suelen responder en 1 día
Todos los issues de wso2/api-platform
Issues similares
-
benchmark
Dificultad 1/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
mozilla-ai/cq#601 ·
Los mantenedores suelen responder en 1 día
-
documentation migration
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día