Repository navigation
fix(websocket): support Sentinel and full TLS options for Redis/Valkey - #45355
Conversation
The WebSocket server could not connect to Redis/Valkey deployments that the Python backend officially supports, so realtime push failed against them: - Sentinel: the server only accepted a fixed host:port, so it could not resolve the master through Sentinel or follow a failover. - TLS: there was no way to set a CA bundle, client certificate/key or verification mode, and hostname validation was not settable via env. Add sslCaCerts/sslCertfile/sslKeyfile/sslCertReqs (REDIS_SSL_*), REDIS_VALIDATE_HOSTNAME, and sentinels/sentinelMaster/sentinelPassword (REDIS_SENTINEL*). A custom CA is trusted in addition to the public roots, and failover detection lets the subscriber follow a promoted master.
a86d34e to
69b82b2
Compare
CodeAnt PR Risk: Low Risk
Assessed commit: |
The websocket server only received REDIS_SSL, so it could not connect to a Valkey that uses a private CA, requires a client certificate, or disables verification, while the app connected fine. Superset 7.0 (apache/superset#45355) adds REDIS_SSL_CA_CERTS, REDIS_SSL_CERTFILE, REDIS_SSL_KEYFILE and REDIS_SSL_CERT_REQS, so pass spec.valkey.ssl through them. Both sides now read the same resolved Valkey input, with the verification mode defaulting to "required" in one place. Co-Authored-By: Claude Opus 5.5 <[email protected]>
spec.valkey.sentinel (masterName, nodes, password/passwordFrom) replaces host/port with a primary that Sentinel resolves, so every Valkey consumer follows it across failovers: - the caches and the SQL Lab results backend use a client bound to the resolved primary. Flask-Caching's RedisSentinelCache reads from replicas, which would break reading filter state, explore permalinks, and SQL Lab results right after writing them; - the coordination backend uses Superset's RedisSentinelCache mode; - Celery uses ";"-separated sentinel:// URLs with the master name and sentinel password as transport options; - the websocket server gets REDIS_SENTINELS, REDIS_SENTINEL_MASTER and REDIS_SENTINEL_PASSWORD (apache/superset#45355). REDIS_SENTINELS is built from the per-node env vars by $(VAR) expansion, so Secret-sourced addresses work too. Each node takes host/hostFrom and port/portFrom (default 26379), following the literal/*From convention for provisioner-published connection values. The sentinel password is Development-only inline, like the other secrets. TLS and the Valkey credentials apply to the primary; the sentinels are contacted in plaintext, as on the Superset side. Co-Authored-By: Claude Opus 5.5 <[email protected]>
madhushreeag
left a comment
There was a problem hiding this comment.
Since ssl: true is silently ignored, ioredis 6 only applies pls to the Sentinel-resolved master when enableTLSForSentinelMode: true is also set, otherwise it falls back to net.createConnection. So the master connection is plaintext - it either fails against a TLS-only master or sends the password and pub/sub traffic unencrypted. The test expect(opts).not.toHaveProperty('enableTLSForSentinelMode') currently locks this in - setting the flag when ssl and sentinels are both set (and flipping that assertion) should fix it.
|
Thanks @madhushreeag, you're right. In ioredis 6's |
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Follow-up to the Sentinel TLS discussion above: the sentinel nodes were also left in plaintext (copied from the Python backend's limitation), which can't work in a TLS-only deployment. Added |
|
Scoping update: I removed the |
SUMMARY
The WebSocket server does not work with Redis/Valkey modes that Superset officially supports. The Python coordination backend (
DISTRIBUTED_COORDINATION_CONFIG) supports standalone and Sentinel, each with full TLS options, and the WebSocket server must connect to the same Redis/Valkey. In practice:host/port, so it cannot resolve the master through Sentinel or follow a failover. Python publishes to the Sentinel-resolved master while the WebSocket server cannot find it, so realtime push is broken on any Sentinel deployment.validateHostnamecan only be set inconfig.json, which the container images (env-only) don't use. Deployments whose Valkey requires mutual TLS or a private CA cannot connect.This fixes both by bringing the Node server's connection options to parity with the Python backend:
sslCaCerts(REDIS_SSL_CA_CERTS) is trusted in addition to Node's public CA roots, matching Python, so public and private CAs work together. With no CA configured, public CAs already work with justssl: true.sslCertfile/sslKeyfileenable mutual TLS.sslCertReqsacceptsrequired,optionalornone; onlynoneskips verification (for a TLS client Python'soptionalis equivalent torequired), and an invalid value falls back torequired.validateHostnamegains aREDIS_VALIDATE_HOSTNAMEenv override.sentinels(REDIS_SENTINELS=host:port,...) enables Sentinel mode, withsentinelMaster(required) andsentinelPassword.failoverDetectoris enabled so the Pub/Sub subscriber drops a demoted master and re-resolves the new one.As on the Python side, TLS applies to the resolved master and the sentinel nodes are contacted in plaintext; TLS to sentinel nodes is out of scope here and is planned as a follow-up covering both the Python and WebSocket sides. Redis Cluster is not supported by either side. Socket timeouts and
force_master_iphave no equivalent here; ioredis defaults apply. Standalone behavior and defaults are unchanged.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A
TESTING INSTRUCTIONS
cd superset-websocket && npm test. New unit tests coverbuildRedisOpts(standalone, TLS, custom CA plus public roots using real temp PEM files, missing cert file, Sentinel, missing master name) and the new env overrides. To verify manually, start the server withREDIS_SENTINELS/REDIS_SENTINEL_MASTERagainst a Sentinel setup, or withREDIS_SSL=trueandREDIS_SSL_CA_CERTSagainst a TLS-enabled Valkey, and confirm/readyreturns 200.ADDITIONAL INFORMATION