wso2 / wso2/api-platform

Consolidate route-vhost config: gateway_host (WebSub) vs vhosts (REST)

Open
#3,322 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area/EventGateway Area/Gateway Aspect/Configuration Type/Improvement
Dominant language
Go
Stars
71
Forks
111
Avg merge
1d 14h
Merged PRs (30d)
110

Description

Description

The platform derives a route's vhost from two different config keys depending on which half of the gateway handles the request, which is inconsistent and confusing.

  • Main gateway (REST / LLM / MCP): the route vhost comes from router.vhosts.main / router.vhosts.sandbox. The router.gateway_host value is never read on this path.
  • Event gateway (WebSub): the route vhost comes from router.gateway_host. The vhosts config is never read on this path.

So the same conceptual field — "the vhost segment of a route key" — is sourced from vhosts in one component and gateway_host in the other.

Evidence:

  • Event gateway uses gateway_host as the vhost when building SUB/UNSUB policy-chain route keys: event-gateway/gateway-controller/pkg/policyhooks/event_channel_translator.go:368 and :399 call xds.GenerateRouteName("SUB"/"UNSUB", apiData.Context, apiData.Version, chName, routerConfig.GatewayHost).
  • GenerateRouteName(method, context, apiVersion, path, vhost string) (gateway/gateway-controller/pkg/xds/translator.go:168) uses that 5th argument as the route key's vhost segment.
  • The event-gateway shares the main controller's config struct (event_channel_translator.go:32 imports github.com/wso2/api-platform/gateway/gateway-controller/pkg/config), so both keys live on the same RouterConfig.
  • The main gateway's REST/LLM/MCP translation uses getVHostDomains / the vhosts config exclusively (gateway/gateway-controller/pkg/xds/translator.go:974-1013) and never reads GatewayHost.

Important: gateway_host is therefore NOT dead config — it is load-bearing for event-gateway route naming. It is only unused within the main gateway, which makes it look removable at a glance. Removing it would break WebSub route-key generation.

Why this matters

An operator configuring the gateway sees both router.gateway_host and router.vhosts.* and has no way to tell that one governs WebSub and the other governs REST. Changing gateway_host has no effect on REST APIs; changing vhosts has no effect on WebSub. This is closely related to the default vs domains confusion tracked in #3321.

Proposal (pick/refine)
  • Preferred: unify the WebSub route-vhost derivation with the same vhosts config the main gateway uses, so there is a single source of truth for a route's vhost, and deprecate router.gateway_host.
  • Or, if they must stay separate: document explicitly that gateway_host governs only the event-gateway (WebSub) and vhosts governs only REST/LLM/MCP, and consider validating/warning when one is set in a deployment that doesn't use it.
  • Either way, add a code comment on RouterConfig.GatewayHost (gateway/gateway-controller/pkg/config/config.go:542) noting it is consumed by the event-gateway, so it is not mistaken for dead config and removed.
Affected areas
  • gateway/gateway-controller/pkg/config/config.go (RouterConfig.GatewayHost)
  • event-gateway/gateway-controller/pkg/policyhooks/event_channel_translator.go
  • gateway/gateway-controller/pkg/xds/translator.go (GenerateRouteName, getVHostDomains)
  • kubernetes/helm/gateway-helm-chart/values.yaml + templates/gateway/gateway-config.yaml
  • kubernetes/helm/operator-helm-chart/values.yaml, kubernetes/gateway-operator/config/*
Version

No response

Related Issue

Related to #3321 and #403 (which introduced the vhosts config for the main gateway, leaving gateway_host used only by the event-gateway).

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading RouterConfig.GatewayHost in gateway/gateway-controller/pkg/config/config.go, the GenerateRouteName and getVHostDomains paths in gateway/gateway-controller/pkg/xds/translator.go, and the WebSub call sites in event-gateway/gateway-controller/pkg/policyhooks/event_channel_translator.go. Then inspect the listed Helm and operator configuration files; done means the chosen vhost configuration behavior is consistent or explicitly documented, with affected configuration and safeguards updated without breaking WebSub route keys.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, helm, kubernetes
Domain
api, backend, infrastructure
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.