sadpandajoe commented on code in PR #43843:
URL: https://github.com/apache/superset/pull/43843#discussion_r3930448328


##########
tests/unit_tests/tasks/test_manager.py:
##########
@@ -99,6 +113,13 @@ def test_get_completion_channel_custom_prefix(self):
             == "custom:complete:test-uuid"
         )
 
+    def test_get_realtime_channel(self):
+        assert TaskManager.get_realtime_channel() == "realtime"
+
+    def test_get_realtime_channel_custom_prefix(self):
+        TaskManager._realtime_channel_prefix = "tenant-a:"

Review Comment:
   This only checks the helper after directly changing its private state, so it 
would still pass if `_publish_realtime` reverted to the literal `realtime` 
channel. A deployment with a configured prefix would then have the websocket 
subscribed to `tenant-a:realtime` while all producer nudges are published to 
`realtime`. Could this initialize the manager with `REALTIME_CHANNEL_PREFIX` 
and invoke a public realtime publisher while asserting 
`CoordinationService.publish` receives the prefixed channel?



##########
superset/config.py:
##########
@@ -3015,6 +3015,15 @@ def EMAIL_HEADER_MUTATOR(  # pylint: 
disable=invalid-name,unused-argument  # noq
 WEBSOCKET_JWT_COOKIE_DOMAIN = None
 WEBSOCKET_JWT_EXPIRATION_SECONDS = int(timedelta(minutes=15).total_seconds())
 
+# Prefix for the realtime pub/sub channel (default ""). Redis pub/sub is not
+# scoped by DB number, so deployments sharing one Redis/Valkey would 
cross-deliver
+# realtime envelopes (opaque entity-change + task-status nudges) — 
cross-tenant id
+# leakage and spurious refetches. Set a per-deployment value (e.g. 
"<keyPrefix>:")
+# here AND on the websocket server (REALTIME_CHANNEL_PREFIX env) to isolate 
them.
+# May be a string or a zero-argument callable, resolved once at startup, 
mirroring
+# Superset's other cache-key helpers. Empty is a no-op for single-instance 
setups.
+REALTIME_CHANNEL_PREFIX: Callable[[], str] | str = ""

Review Comment:
   The websocket README still calls the `realtime` channel fixed and tells 
operators to allow only that Redis ACL channel. With this new prefix, an 
operator who configures `tenant-a:` on both sides will have the server 
subscribe to `tenant-a:realtime`, which that documented ACL denies; the 
subscription then retries and no realtime nudges arrive. Could the operator 
docs and coordination table describe both producer and websocket prefix 
settings and the resulting ACL channel?



-- 
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