Skip to content

fix(xds): correct endpoint config generation for API gateway in peered setups#23370

Merged
LordAbhishek merged 2 commits into
propogate_meshGatewayConfig_to_APIGW_upstreamsfrom
fix_endpoints_config_for_api_gw_peering
Apr 13, 2026
Merged

fix(xds): correct endpoint config generation for API gateway in peered setups#23370
LordAbhishek merged 2 commits into
propogate_meshGatewayConfig_to_APIGW_upstreamsfrom
fix_endpoints_config_for_api_gw_peering

Conversation

@LordAbhishek
Copy link
Copy Markdown
Contributor

@LordAbhishek LordAbhishek commented Mar 24, 2026

fix(xds): correct endpoint config generation for API gateway in peered setups

Issue:

  • Previously, API gateway XDS endpoint generation incorrectly relied on cfgSnap.ConnectProxy config (instead of cgfSnap.APIGateway), which caused wrong/no endpoint configuration for peered environments.

Fix (Changes made):

  • Updated makeUpstreamLoadAssignmentForPeerService to fetch localGatewayEndpoint based on cfgSnap kind instead of always using cfgSnap.ConnectProxy.
    If not updated, api-gw always never generates endpoint configs.
  • Updated endpointsFromDiscoveryChain to derive meshGatewayMode based on cfgSnap kind instead of always using cfgSnap.ConnectProxy.
    If not updated, in case of peering, when api gw meshGateway.mode is confgured to local, it always fallback to remote mesh mode.. due to which it never routes to its upstream via local mesh gateway. It will be configured directly to talk with remote mesh gw.
  • Recompiled golden test file to reflect fix.

Verification:
We can verify the golden file that are generated after the fix.

How the fix is tested:

Unit test cases:
$ go test ./agent/xds -run 'TestAllResourcesFromSnapshot/.*/api-gateway-with-peers-mesh-mode-(local|remote)-and-upstream-is-(hostname|static)' -count=1 -update

ok github.com/hashicorp/consul/agent/xds 0.491s
$ go test ./agent/xds
ok github.com/hashicorp/consul/agent/xds 1.924s
$ go test ./agent/proxycfg
ok github.com/hashicorp/consul/agent/proxycfg 5.105s

Consul-k8s acceptance tests:

Built the consul-ent patch image with the same changes:
Ran the consul-k8s workflow with the patched consul-ent image.
All peering test ran fine on both EKS and Kind.
Kind test: https://github.com/hashicorp/consul-k8s-workflows/actions/runs/22376072101
EKS test: https://github.com/hashicorp/consul-k8s-workflows/actions/runs/22376066354

…d setups

- Previously, API gateway XDS endpoint generation incorrectly relied on cfgSnap.ConnectProxy config (instead of cgfSnap.APIGateway), which caused wrong/no endpoint configuration for peered environments.
- Changes made:
- Updated makeUpstreamLoadAssignmentForPeerService to fetch localGatewayEndpoint based on cfgSnap kind instead of always using cfgSnap.ConnectProxy.
- Updated endpointsFromDiscoveryChain to derive meshGatewayMode based on cfgSnap kind instead of always using cfgSnap.ConnectProxy.
- Recompiled golden test file to reflect fix.
@github-actions github-actions Bot added the theme/envoy/xds Related to Envoy support label Mar 24, 2026
@LordAbhishek LordAbhishek marked this pull request as ready for review March 26, 2026 05:30
@LordAbhishek LordAbhishek requested review from a team as code owners March 26, 2026 05:30
Copy link
Copy Markdown
Contributor

@anandmukul93 anandmukul93 left a comment

Choose a reason for hiding this comment

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

LGTM

@LordAbhishek LordAbhishek merged commit 5084015 into propogate_meshGatewayConfig_to_APIGW_upstreams Apr 13, 2026
58 of 60 checks passed
LordAbhishek added a commit that referenced this pull request Apr 13, 2026
#23369)

* fix(proxyCfg): propogate meshGatewayConfig to upstreams of API gateway

- Fixed handleRouteConfigUpdate to properly propagate meshGatewayConfig to API gateway upstreams, which is required during XDS endpoint and cluster config generation.
- Added TestStateChangedAPIGateway test cases in state_test.go to validate API gateway update handling.
- Added API gateway-specific logging prefix (similar to mesh gateway) to help in debugging.

* fix(xds): correct endpoint config generation for API gateway in peered setups (#23370)

* fix(xds): correct endpoint config generation for API gateway in peered setups

- Previously, API gateway XDS endpoint generation incorrectly relied on cfgSnap.ConnectProxy config (instead of cgfSnap.APIGateway), which caused wrong/no endpoint configuration for peered environments.
- Changes made:
- Updated makeUpstreamLoadAssignmentForPeerService to fetch localGatewayEndpoint based on cfgSnap kind instead of always using cfgSnap.ConnectProxy.
- Updated endpointsFromDiscoveryChain to derive meshGatewayMode based on cfgSnap kind instead of always using cfgSnap.ConnectProxy.
- Recompiled golden test file to reflect fix.

* removed comment

* fix(xds): correct cluster config generation for API gateway in peered setups (#23371)

* fix(xds): correct cluster config generation for API gateway in peered setups

- Updated makeUpstreamClustersForDiscoveryChain to generate cluster config based on upstream endpoint type. Before this fix, it always generated cluster configs without endpoints, which is incorrect when the upstream endpoint type is hostname and mesh-gateway mode is remote; in such cases, endpoints must also be included in the cluster config.

- Added recompiled golden test file to reflect the fix.

* fix lint error
LordAbhishek added a commit that referenced this pull request Apr 13, 2026
* add unit test cases for api gateway supporting consul peering

* add compiled xds config golden files after running api-gw golden testcases

* fix(proxyCfg): propogate meshGatewayConfig to upstreams of API gateway (#23369)

* fix(proxyCfg): propogate meshGatewayConfig to upstreams of API gateway

- Fixed handleRouteConfigUpdate to properly propagate meshGatewayConfig to API gateway upstreams, which is required during XDS endpoint and cluster config generation.
- Added TestStateChangedAPIGateway test cases in state_test.go to validate API gateway update handling.
- Added API gateway-specific logging prefix (similar to mesh gateway) to help in debugging.

* fix(xds): correct endpoint config generation for API gateway in peered setups (#23370)

* fix(xds): correct endpoint config generation for API gateway in peered setups

- Previously, API gateway XDS endpoint generation incorrectly relied on cfgSnap.ConnectProxy config (instead of cgfSnap.APIGateway), which caused wrong/no endpoint configuration for peered environments.
- Changes made:
- Updated makeUpstreamLoadAssignmentForPeerService to fetch localGatewayEndpoint based on cfgSnap kind instead of always using cfgSnap.ConnectProxy.
- Updated endpointsFromDiscoveryChain to derive meshGatewayMode based on cfgSnap kind instead of always using cfgSnap.ConnectProxy.
- Recompiled golden test file to reflect fix.

* removed comment

* fix(xds): correct cluster config generation for API gateway in peered setups (#23371)

* fix(xds): correct cluster config generation for API gateway in peered setups

- Updated makeUpstreamClustersForDiscoveryChain to generate cluster config based on upstream endpoint type. Before this fix, it always generated cluster configs without endpoints, which is incorrect when the upstream endpoint type is hostname and mesh-gateway mode is remote; in such cases, endpoints must also be included in the cluster config.

- Added recompiled golden test file to reflect the fix.

* fix lint error
LordAbhishek added a commit that referenced this pull request Apr 13, 2026
* add unit test cases for api gateway supporting consul peering

* add compiled xds config golden files after running api-gw golden testcases

* fix(proxyCfg): propogate meshGatewayConfig to upstreams of API gateway (#23369)

* fix(proxyCfg): propogate meshGatewayConfig to upstreams of API gateway

- Fixed handleRouteConfigUpdate to properly propagate meshGatewayConfig to API gateway upstreams, which is required during XDS endpoint and cluster config generation.
- Added TestStateChangedAPIGateway test cases in state_test.go to validate API gateway update handling.
- Added API gateway-specific logging prefix (similar to mesh gateway) to help in debugging.

* fix(xds): correct endpoint config generation for API gateway in peered setups (#23370)

* fix(xds): correct endpoint config generation for API gateway in peered setups

- Previously, API gateway XDS endpoint generation incorrectly relied on cfgSnap.ConnectProxy config (instead of cgfSnap.APIGateway), which caused wrong/no endpoint configuration for peered environments.
- Changes made:
- Updated makeUpstreamLoadAssignmentForPeerService to fetch localGatewayEndpoint based on cfgSnap kind instead of always using cfgSnap.ConnectProxy.
- Updated endpointsFromDiscoveryChain to derive meshGatewayMode based on cfgSnap kind instead of always using cfgSnap.ConnectProxy.
- Recompiled golden test file to reflect fix.

* removed comment

* fix(xds): correct cluster config generation for API gateway in peered setups (#23371)

* fix(xds): correct cluster config generation for API gateway in peered setups

- Updated makeUpstreamClustersForDiscoveryChain to generate cluster config based on upstream endpoint type. Before this fix, it always generated cluster configs without endpoints, which is incorrect when the upstream endpoint type is hostname and mesh-gateway mode is remote; in such cases, endpoints must also be included in the cluster config.

- Added recompiled golden test file to reflect the fix.

* fix lint error
LordAbhishek added a commit that referenced this pull request Apr 13, 2026
* add unit test cases for api gateway supporting consul peering

* add compiled xds config golden files after running api-gw golden testcases

* fix(proxyCfg): propogate meshGatewayConfig to upstreams of API gateway (#23369)

* fix(proxyCfg): propogate meshGatewayConfig to upstreams of API gateway

- Fixed handleRouteConfigUpdate to properly propagate meshGatewayConfig to API gateway upstreams, which is required during XDS endpoint and cluster config generation.
- Added TestStateChangedAPIGateway test cases in state_test.go to validate API gateway update handling.
- Added API gateway-specific logging prefix (similar to mesh gateway) to help in debugging.

* fix(xds): correct endpoint config generation for API gateway in peered setups (#23370)

* fix(xds): correct endpoint config generation for API gateway in peered setups

- Previously, API gateway XDS endpoint generation incorrectly relied on cfgSnap.ConnectProxy config (instead of cgfSnap.APIGateway), which caused wrong/no endpoint configuration for peered environments.
- Changes made:
- Updated makeUpstreamLoadAssignmentForPeerService to fetch localGatewayEndpoint based on cfgSnap kind instead of always using cfgSnap.ConnectProxy.
- Updated endpointsFromDiscoveryChain to derive meshGatewayMode based on cfgSnap kind instead of always using cfgSnap.ConnectProxy.
- Recompiled golden test file to reflect fix.

* removed comment

* fix(xds): correct cluster config generation for API gateway in peered setups (#23371)

* fix(xds): correct cluster config generation for API gateway in peered setups

- Updated makeUpstreamClustersForDiscoveryChain to generate cluster config based on upstream endpoint type. Before this fix, it always generated cluster configs without endpoints, which is incorrect when the upstream endpoint type is hostname and mesh-gateway mode is remote; in such cases, endpoints must also be included in the cluster config.

- Added recompiled golden test file to reflect the fix.

* fix lint error
LordAbhishek added a commit that referenced this pull request Apr 22, 2026
* add unit test cases for api gateway supporting consul peering

* add compiled xds config golden files after running api-gw golden testcases

* fix(proxyCfg): propogate meshGatewayConfig to upstreams of API gateway (#23369)

* fix(proxyCfg): propogate meshGatewayConfig to upstreams of API gateway

- Fixed handleRouteConfigUpdate to properly propagate meshGatewayConfig to API gateway upstreams, which is required during XDS endpoint and cluster config generation.
- Added TestStateChangedAPIGateway test cases in state_test.go to validate API gateway update handling.
- Added API gateway-specific logging prefix (similar to mesh gateway) to help in debugging.

* fix(xds): correct endpoint config generation for API gateway in peered setups (#23370)

* fix(xds): correct endpoint config generation for API gateway in peered setups

- Previously, API gateway XDS endpoint generation incorrectly relied on cfgSnap.ConnectProxy config (instead of cgfSnap.APIGateway), which caused wrong/no endpoint configuration for peered environments.
- Changes made:
- Updated makeUpstreamLoadAssignmentForPeerService to fetch localGatewayEndpoint based on cfgSnap kind instead of always using cfgSnap.ConnectProxy.
- Updated endpointsFromDiscoveryChain to derive meshGatewayMode based on cfgSnap kind instead of always using cfgSnap.ConnectProxy.
- Recompiled golden test file to reflect fix.

* removed comment

* fix(xds): correct cluster config generation for API gateway in peered setups (#23371)

* fix(xds): correct cluster config generation for API gateway in peered setups

- Updated makeUpstreamClustersForDiscoveryChain to generate cluster config based on upstream endpoint type. Before this fix, it always generated cluster configs without endpoints, which is incorrect when the upstream endpoint type is hostname and mesh-gateway mode is remote; in such cases, endpoints must also be included in the cluster config.

- Added recompiled golden test file to reflect the fix.

* fix lint error
LordAbhishek added a commit that referenced this pull request Apr 22, 2026
* add unit test cases for api gateway supporting consul peering

* add compiled xds config golden files after running api-gw golden testcases

* fix(proxyCfg): propogate meshGatewayConfig to upstreams of API gateway (#23369)

* fix(proxyCfg): propogate meshGatewayConfig to upstreams of API gateway

- Fixed handleRouteConfigUpdate to properly propagate meshGatewayConfig to API gateway upstreams, which is required during XDS endpoint and cluster config generation.
- Added TestStateChangedAPIGateway test cases in state_test.go to validate API gateway update handling.
- Added API gateway-specific logging prefix (similar to mesh gateway) to help in debugging.

* fix(xds): correct endpoint config generation for API gateway in peered setups (#23370)

* fix(xds): correct endpoint config generation for API gateway in peered setups

- Previously, API gateway XDS endpoint generation incorrectly relied on cfgSnap.ConnectProxy config (instead of cgfSnap.APIGateway), which caused wrong/no endpoint configuration for peered environments.
- Changes made:
- Updated makeUpstreamLoadAssignmentForPeerService to fetch localGatewayEndpoint based on cfgSnap kind instead of always using cfgSnap.ConnectProxy.
- Updated endpointsFromDiscoveryChain to derive meshGatewayMode based on cfgSnap kind instead of always using cfgSnap.ConnectProxy.
- Recompiled golden test file to reflect fix.

* removed comment

* fix(xds): correct cluster config generation for API gateway in peered setups (#23371)

* fix(xds): correct cluster config generation for API gateway in peered setups

- Updated makeUpstreamClustersForDiscoveryChain to generate cluster config based on upstream endpoint type. Before this fix, it always generated cluster configs without endpoints, which is incorrect when the upstream endpoint type is hostname and mesh-gateway mode is remote; in such cases, endpoints must also be included in the cluster config.

- Added recompiled golden test file to reflect the fix.

* fix lint error
LordAbhishek added a commit that referenced this pull request Apr 22, 2026
* add unit test cases for api gateway supporting consul peering

* add compiled xds config golden files after running api-gw golden testcases

* fix(proxyCfg): propogate meshGatewayConfig to upstreams of API gateway (#23369)

* fix(proxyCfg): propogate meshGatewayConfig to upstreams of API gateway

- Fixed handleRouteConfigUpdate to properly propagate meshGatewayConfig to API gateway upstreams, which is required during XDS endpoint and cluster config generation.
- Added TestStateChangedAPIGateway test cases in state_test.go to validate API gateway update handling.
- Added API gateway-specific logging prefix (similar to mesh gateway) to help in debugging.

* fix(xds): correct endpoint config generation for API gateway in peered setups (#23370)

* fix(xds): correct endpoint config generation for API gateway in peered setups

- Previously, API gateway XDS endpoint generation incorrectly relied on cfgSnap.ConnectProxy config (instead of cgfSnap.APIGateway), which caused wrong/no endpoint configuration for peered environments.
- Changes made:
- Updated makeUpstreamLoadAssignmentForPeerService to fetch localGatewayEndpoint based on cfgSnap kind instead of always using cfgSnap.ConnectProxy.
- Updated endpointsFromDiscoveryChain to derive meshGatewayMode based on cfgSnap kind instead of always using cfgSnap.ConnectProxy.
- Recompiled golden test file to reflect fix.

* removed comment

* fix(xds): correct cluster config generation for API gateway in peered setups (#23371)

* fix(xds): correct cluster config generation for API gateway in peered setups

- Updated makeUpstreamClustersForDiscoveryChain to generate cluster config based on upstream endpoint type. Before this fix, it always generated cluster configs without endpoints, which is incorrect when the upstream endpoint type is hostname and mesh-gateway mode is remote; in such cases, endpoints must also be included in the cluster config.

- Added recompiled golden test file to reflect the fix.

* fix lint error
LordAbhishek added a commit that referenced this pull request Apr 22, 2026
…r API Gateways when peered and updated the API Gateway updateHandler to propagate mesh gateway config to its upstreams. (#23454)

* Add api gateway peering unit test cases. (#23366)

* add unit test cases for api gateway supporting consul peering

* add compiled xds config golden files after running api-gw golden testcases

* fix(proxyCfg): propogate meshGatewayConfig to upstreams of API gateway (#23369)

* fix(proxyCfg): propogate meshGatewayConfig to upstreams of API gateway

- Fixed handleRouteConfigUpdate to properly propagate meshGatewayConfig to API gateway upstreams, which is required during XDS endpoint and cluster config generation.
- Added TestStateChangedAPIGateway test cases in state_test.go to validate API gateway update handling.
- Added API gateway-specific logging prefix (similar to mesh gateway) to help in debugging.

* fix(xds): correct endpoint config generation for API gateway in peered setups (#23370)

* fix(xds): correct endpoint config generation for API gateway in peered setups

- Previously, API gateway XDS endpoint generation incorrectly relied on cfgSnap.ConnectProxy config (instead of cgfSnap.APIGateway), which caused wrong/no endpoint configuration for peered environments.
- Changes made:
- Updated makeUpstreamLoadAssignmentForPeerService to fetch localGatewayEndpoint based on cfgSnap kind instead of always using cfgSnap.ConnectProxy.
- Updated endpointsFromDiscoveryChain to derive meshGatewayMode based on cfgSnap kind instead of always using cfgSnap.ConnectProxy.
- Recompiled golden test file to reflect fix.

* removed comment

* fix(xds): correct cluster config generation for API gateway in peered setups (#23371)

* fix(xds): correct cluster config generation for API gateway in peered setups

- Updated makeUpstreamClustersForDiscoveryChain to generate cluster config based on upstream endpoint type. Before this fix, it always generated cluster configs without endpoints, which is incorrect when the upstream endpoint type is hostname and mesh-gateway mode is remote; in such cases, endpoints must also be included in the cluster config.

- Added recompiled golden test file to reflect the fix.

* fix lint error

* add changelog

* refresh golden file to remove regexRewrite from route configs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

theme/envoy/xds Related to Envoy support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants