Gateway onboarding: on-prem APIM support via host + on_prem config#1219
Gateway onboarding: on-prem APIM support via host + on_prem config#1219YasasRangika wants to merge 1 commit intowso2:feature-on-prem-apim-connectionfrom
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
gateway/gateway-controller/pkg/controlplane/controlplane_test.go (1)
249-262: Good test coverage for OnPrem URL construction.The test verifies both
getWebSocketURL()andgetWebSocketConnectURL()for the on-prem case. Consider adding a similar assertion forgetWebSocketConnectURL()in the existingTestClient_getWebSocketURLtest (cloud mode) for completeness.💡 Optional: Add cloud mode getWebSocketConnectURL assertion
// In TestClient_getWebSocketURL, add after line 246: connectURL := client.getWebSocketConnectURL() expectedConnect := expected + "/gateways/connect" if connectURL != expectedConnect { t.Errorf("getWebSocketConnectURL() = %q, want %q", connectURL, expectedConnect) }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@gateway/gateway-controller/pkg/controlplane/controlplane_test.go` around lines 249 - 262, Add the missing assertion for the cloud-mode WebSocket connect URL in the existing TestClient_getWebSocketURL test: after obtaining url and expected, call client.getWebSocketConnectURL(), compute expectedConnect as expected + "/gateways/connect", and assert equality—reporting a useful error via t.Errorf if they differ; this mirrors the OnPrem test's checks and uses the same getWebSocketURL and getWebSocketConnectURL methods for locating the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@gateway/gateway-controller/pkg/controlplane/controlplane_test.go`:
- Around line 249-262: Add the missing assertion for the cloud-mode WebSocket
connect URL in the existing TestClient_getWebSocketURL test: after obtaining url
and expected, call client.getWebSocketConnectURL(), compute expectedConnect as
expected + "/gateways/connect", and assert equality—reporting a useful error via
t.Errorf if they differ; this mirrors the OnPrem test's checks and uses the same
getWebSocketURL and getWebSocketConnectURL methods for locating the change.
Purpose
This PR adds gateway onboarding support so the API Platform Gateway can register and connect to on-prem WSO2 APIM as well as the cloud control plane (Bijira), as described in the design doc "APIM and API Platform Gateway Integration". The same gateway binary is used for both: only configuration changes (host + on-prem flag). No separate WebSocket URL is configured; all URLs are derived from host in code, with the path chosen by on_prem.
Goal
Add gateway onboarding for wso2/api-manager#4665
Approach
1. Configuration (gateway-controller)
ControlPlaneConfig.OnPrem(bool, koanf:on_prem) — Whentrue, use on-prem paths for WebSocket and REST (/internal/data/v1/ws,/internal/data/v1). Whenfalse(default), use cloud paths (/api/internal/v1/ws,/api/internal/v1).GATEWAY_CONTROLPLANE_HOST/APIP_GW_CONTROLPLANE_HOST→controller.controlplane.hostGATEWAY_CONTROLPLANE_ON_PREM/APIP_GW_CONTROLPLANE_ON_PREM→controller.controlplane.on_premGATEWAY_REGISTRATION_TOKEN/APIP_GW_GATEWAY_REGISTRATION_TOKEN→controller.controlplane.tokencontrolplane.hostis required; whenon_premis true, host is required. Existing validation for reconnect/polling intervals unchanged.2. Control plane client (URL building)
getWebSocketURL()wss://{host}/internal/data/v1/wswss://{host}/api/internal/v1/wsgetWebSocketConnectURL()getWebSocketURL() + "/gateways/connect"(path is the same for both modes).getRestAPIBaseURL()https://{host}/internal/data/v1https://{host}/api/internal/v1Connection flow is unchanged: gateway sends registration token in
api-keyheader, waits forconnection.ack, runs heartbeat monitor; reconnection and backoff behaviour are the same for cloud and on-prem.3. Tests
TestClient_getWebSocketURL_OnPrem— Asserts on-prem WebSocket base URL.TestClient_getRestAPIBaseURL_OnPrem— Asserts on-prem REST base URL.createTestClientWithOnPrem(t, onPrem bool)for client tests.Design reference
Aligned with the design doc "APIM and API Platform Gateway Integration" (Section 2: Overview — host + on-prem flag; Section 4.3: Gateway client —
GATEWAY_CONTROLPLANE_HOST,GATEWAY_CONTROLPLANE_ON_PREM, URL building from host in code; same handshake and keep-alive as API Platform).On-prem usage (after control plane is set up)
Summary by CodeRabbit
Release Notes