Skip to content

chore: [ACC-3193] always on HA mode for universal broker#1088

Open
gclapperton wants to merge 1 commit intomasterfrom
feat/remove-ha-mode-flag
Open

chore: [ACC-3193] always on HA mode for universal broker#1088
gclapperton wants to merge 1 commit intomasterfrom
feat/remove-ha-mode-flag

Conversation

@gclapperton
Copy link
Copy Markdown
Contributor

@gclapperton gclapperton commented Mar 3, 2026

What changed

getServerId() — which registers this client connection with the Snyk dispatcher and receives back a server_id used to route websocket traffic in multi-pod deployments — is now called unconditionally when a universal broker client establishes a websocket connection. Previously it was gated behind BROKER_HA_MODE_ENABLED == 'true'. The flag and both conditional blocks in socket.ts are removed.

BROKER_HA_MODE_ENABLED is also removed from all config.universaltest*.json files and from the relevant unit test snapshots in config.test.ts.

Legacy clients are not affected — createWebSocketConnectionPairs is only called when universalBrokerEnabled is true.

Why

Universal broker works in both single-pod and multi-pod deployments, but we want to make scaling to multiple pods as seamless as possible. Since single-pod deployments can participate in server-side routing (HA mode) without any downside, we default to it — so that customers going from one pod to many only need to increase their replica count, with no config changes required.

Test infrastructure

With getServerId() now unconditional, every test that starts a universal broker client makes a dispatcher request against API_BASE_URL. Previously tests were pointing that variable at the broker server or the TestWebServer, neither of which speaks the dispatcher API, causing those calls to fail or hit unexpected routes.

This PR introduces TestApiServer (test/setup/test-api-server.ts): a lightweight Express mock of api.snyk.io that handles the two dispatcher endpoints (/hidden/broker/… and /hidden/brokers/…) and the webhook fallback endpoints that the broker client posts to when the websocket is down. All universal broker functional tests now start a TestApiServer alongside the broker server and web server. The webhook routes that were previously on TestWebServer are removed from there and live only on TestApiServer.

@snyk-io
Copy link
Copy Markdown
Contributor

snyk-io bot commented Mar 3, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@snyk-io
Copy link
Copy Markdown
Contributor

snyk-io bot commented Mar 3, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@gclapperton gclapperton force-pushed the feat/remove-ha-mode-flag branch from 2279f03 to 0740838 Compare March 4, 2026 20:06
@gclapperton gclapperton force-pushed the feat/remove-ha-mode-flag branch from 0740838 to c430576 Compare March 19, 2026 15:37
expect(httpChecks[0].enabled).toEqual(true);
});

it('should return false for rest-api-status.enabled if high availability mode is off', async () => {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This test appears to have been broken as it asserts that enabled is true

@gclapperton gclapperton force-pushed the feat/remove-ha-mode-flag branch 3 times, most recently from dacadcc to 356ed26 Compare March 26, 2026 15:42
@gclapperton gclapperton force-pushed the feat/remove-ha-mode-flag branch 6 times, most recently from 010a521 to e85b06c Compare March 31, 2026 01:20
…A_MODE_ENABLED

Universal broker clients now always call getServerId() when establishing
websocket connections. The BROKER_HA_MODE_ENABLED flag and its conditional
gate in socket.ts are removed — getServerId() should always run for universal
broker. Legacy clients are unaffected; createWebSocketConnectionPairs is only
invoked when universalBrokerEnabled is true.

Test infrastructure: introduce TestApiServer (test/setup/test-api-server.ts),
a dedicated mock of api.snyk.io that handles dispatcher allocation and webhook
fallback endpoints. Previously tests pointed API_BASE_URL at the broker server
or web server, which broke once getServerId() became unconditional. All
universal broker functional tests now spin up a TestApiServer alongside the
broker server and web server, and webhook routes that belong to the API layer
are moved out of TestWebServer.
@gclapperton gclapperton force-pushed the feat/remove-ha-mode-flag branch from 571c337 to 9acbfa7 Compare March 31, 2026 18:22
@gclapperton gclapperton changed the title Remove HA mode flag and make dispatcher always-on Always on HA mode for universal broker Mar 31, 2026
@gclapperton gclapperton changed the title Always on HA mode for universal broker chore: Always on HA mode for universal broker Mar 31, 2026
@gclapperton gclapperton changed the title chore: Always on HA mode for universal broker chore: [ACC-3193] always on HA mode for universal broker Mar 31, 2026
@gclapperton gclapperton marked this pull request as ready for review March 31, 2026 18:49
@gclapperton gclapperton requested review from a team as code owners March 31, 2026 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant