[Bug]: Updating a REST API on the gateway doesn't resolve its vhosts, so _gateway_default_ is stored as a hostname

Abierto Apto para principiantes
#4,167 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
78/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
go
Área
api, backend

Línea de trabajo

Lee gateway/gateway-controller/pkg/service/restapi/service.go, especialmente RestAPIService.Update y la ruta de creación a través de DeployAPIConfiguration; compara cómo gestiona cada una los vhosts. Después, inspecciona gateway/gateway-controller/pkg/utils/api_deployment.go y su función resolveVhostSentinels. El trabajo estará terminado cuando las actualizaciones resuelvan _gateway_default_ y los vhosts ausentes a los valores predeterminados actuales del gateway, y GET devuelva los valores resueltos; comprueba si existen pruebas de actualización de la REST API para confirmar este comportamiento.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Area/Gateway Aspect/API Severity/Major Type/Bug
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)

Description

When a REST API is created on the gateway, its vhosts are resolved at deploy time: _gateway_default_, or a missing vhosts block, becomes the gateway's current default hosts. The resolved values are stored, so a later change to the gateway defaults doesn't move the API (discussion #369).

Updating the API through the gateway's REST API (PUT /rest-apis/{id}) skips that step:

  • With vhosts.main: _gateway_default_: the placeholder is stored literally, as a hostname. The API stops answering on the default hosts.
  • With no vhosts block: nothing is stored. The API keeps answering on the defaults only because the router falls back to the live default. So it follows the next config change, which is what deploy-time resolution is meant to prevent, and GET shows no vhosts.

Observed (gateway with router.vhosts.main.default = "*.wso2.com" and router.vhosts.sandbox.default = "*-sandbox.wso2.com")

  1. POST /rest-apis with no vhosts: GET /rest-apis/{id} shows spec.vhosts.main *.wso2.com and spec.vhosts.sandbox *-sandbox.wso2.com, and a request with Host: api.wso2.com answers 200.
  2. PUT /rest-apis/{id} with vhosts: {"main": "_gateway_default_"}: GET shows spec.vhosts.main _gateway_default_, and the same request now answers 404.
  3. PUT /rest-apis/{id} with no vhosts: GET shows no spec.vhosts at all.

Expected
An update resolves vhosts the same way a create does. _gateway_default_ and a missing vhosts block become the current gateway defaults, which are stored and shown by GET.

Cause
Create goes through DeployAPIConfiguration (gateway/gateway-controller/pkg/service/restapi/service.go:174), which calls resolveVhostSentinels (gateway/gateway-controller/pkg/utils/api_deployment.go:312). RestAPIService.Update (pkg/service/restapi/service.go:320) parses the body and saves it without that call. The event gateway's WebSub update does resolve vhosts, because it goes through DeployAPIConfiguration.

Steps to Reproduce
  1. Start a gateway with [router.vhosts.main] default = "*.wso2.com".
  2. Create a REST API with no vhosts through POST /rest-apis. A request with Host: api.wso2.com answers 200.
  3. Update it through PUT /rest-apis/{id} with "vhosts": {"main": "_gateway_default_"}.
  4. GET /rest-apis/{id} shows _gateway_default_, and the request with Host: api.wso2.com answers 404.
  5. Update it again with no vhosts: GET shows no vhosts.
Severity Level of the Issue

Severity/Major (Important functionality is broken. Should be prioritized. Doesn't need immediate attention)

Environment Details (with versions)

Current main (e90cde473). Platform-api and gateway built from source and run by the IT suite (tests/framework), on macOS with Rancher Desktop.

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

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de wso2/api-platform

Todos los issues de wso2/api-platform

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.