villebro opened a new pull request, #43843:
URL: https://github.com/apache/superset/pull/43843

   ### SUMMARY
   
   Redis Pub/Sub is **not** scoped by DB number, so multiple Superset 
deployments sharing one Redis/Valkey cross-deliver realtime envelopes (opaque 
entity-change + task-status nudges) — cross-tenant id leakage and spurious 
refetches. All other coordination state is already namespaceable (cache key 
prefix, `TASKS_ABORT_CHANNEL_PREFIX` / `TASKS_COMPLETION_CHANNEL_PREFIX`); only 
this Pub/Sub channel was hardcoded to `"realtime"` on both the producer 
(`superset/tasks/manager.py`) and the consumer 
(`superset-websocket/src/index.ts`).
   
   This PR adds `REALTIME_CHANNEL_PREFIX` (default `""`, a no-op for 
single-instance deployments) so an operator can namespace the channel per 
deployment:
   
   - **Superset (producer):** the channel is now `"<prefix>realtime"`, resolved 
via a new `TaskManager.get_realtime_channel()` classmethod. The prefix may be a 
**string or a zero-argument callable resolved at publish time**, mirroring 
Superset's existing cache-key pattern (`KeyLike` in 
`superset/coordination/base.py`, and `SLACK_API_TOKEN` / 
`GUEST_TOKEN_JWT_AUDIENCE`).
   - **websocket server (consumer):** reads `REALTIME_CHANNEL_PREFIX` from the 
environment (via `config.ts`) and subscribes to `"<prefix>realtime"`.
   
   An operator sets `REALTIME_CHANNEL_PREFIX` identically on both sides (e.g. 
`"<keyPrefix>:"`) to make a shared Redis/Valkey safe. This isolates the shared 
**Redis instance**; the topology remains one websocket server per deployment 
(the server subscribes to a single channel, and routing keys / JWT secret are 
per-deployment).
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   N/A — configuration/backend change.
   
   ### TESTING INSTRUCTIONS
   
   - `pytest tests/unit_tests/tasks/test_manager.py`
   - `cd superset-websocket && npm test -- spec/config.test.ts 
spec/index.test.ts && npm run lint`
   - Manual: set `REALTIME_CHANNEL_PREFIX = "tenantA:"` in `superset_config.py` 
and `REALTIME_CHANNEL_PREFIX=tenantA:` on the websocket container; confirm the 
producer publishes to `tenantA:realtime` and the server subscribes to the same, 
while a second deployment with a different prefix sees no cross-delivery.
   
   ### ADDITIONAL INFORMATION
   
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [x] Introduces new feature or API
   - [ ] Removes existing feature or API


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to