Skip to content

fix(websocket): support Sentinel and full TLS options for Redis/Valkey - #45355

Merged
villebro merged 5 commits into
apache:masterfrom
villebro:villebro/websocket-redis-modes
Oct 16, 2026
Merged

villebro merged 5 commits into
apache:masterfrom
villebro:villebro/websocket-redis-modes

Conversation

@villebro

@villebro villebro commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

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:

  • Sentinel: the server only accepts a fixed 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.
  • TLS: there is no way to configure a CA bundle, client certificate/key or verification mode, and validateHostname can only be set in config.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:

  • TLS: 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 just ssl: true. sslCertfile/sslKeyfile enable mutual TLS. sslCertReqs accepts required, optional or none; only none skips verification (for a TLS client Python's optional is equivalent to required), and an invalid value falls back to required. validateHostname gains a REDIS_VALIDATE_HOSTNAME env override.
  • Sentinel: setting sentinels (REDIS_SENTINELS=host:port,...) enables Sentinel mode, with sentinelMaster (required) and sentinelPassword. failoverDetector is enabled so the Pub/Sub subscriber drops a demoted master and re-resolves the new one.
  • A missing cert file fails fast at startup.

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_ip have 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 cover buildRedisOpts (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 with REDIS_SENTINELS/REDIS_SENTINEL_MASTER against a Sentinel setup, or with REDIS_SSL=true and REDIS_SSL_CA_CERTS against a TLS-enabled Valkey, and confirm /ready returns 200.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@villebro villebro changed the title feat(websocket): support Sentinel and full TLS options for Redis/Valkey fix(websocket): support Sentinel and full TLS options for Redis/Valkey Oct 15, 2026
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.
@villebro
villebro force-pushed the villebro/websocket-redis-modes branch from a86d34e to 69b82b2 Compare October 15, 2026 18:44
Comment thread superset-websocket/src/config.ts Resolved
@codeant-ai-for-open-source

codeant-ai-for-open-source Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

CodeAnt PR Risk: Low Risk

  • The PR appears safe to merge; focused tests cover Redis standalone, Sentinel, and TLS option construction.
  • Sentinel address parsing rejects invalid and out-of-range ports, with malformed entries covered by the environment-override test.

Assessed commit: 884d91858585

villebro added a commit to villebro/superset-kubernetes-operator that referenced this pull request Oct 15, 2026
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]>
villebro added a commit to villebro/superset-kubernetes-operator that referenced this pull request Oct 15, 2026
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 madhushreeag left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@villebro

Copy link
Copy Markdown
Member Author

Thanks @madhushreeag, you're right. In ioredis 6's SentinelConnector, tls is only applied to the resolved master when enableTLSForSentinelMode is set; otherwise it uses a plain net.createConnection, so ssl: true was silently ignored in Sentinel mode and my test locked that in. Fixed in 884d918: the flag is now set whenever ssl and sentinels are both configured, and the test asserts it. Sentinel nodes themselves still use sentinelTLS (unset), so they remain plaintext as on the Python side.

@netlify

netlify Bot commented Oct 15, 2026

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 884d918
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6ad161bf580d15d37da71a98
😎 Deploy Preview https://deploy-preview-45355--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@villebro

Copy link
Copy Markdown
Member Author

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 sentinelSsl / REDIS_SENTINEL_SSL in e757bff; ssl secures the master and sentinelSsl the sentinel nodes, using the same CA/client-cert/verification settings. It defaults to false, so existing plaintext-sentinel setups are unchanged. Also removed the test that asserted TLS master with plaintext sentinels.

@villebro

Copy link
Copy Markdown
Member Author

Scoping update: I removed the sentinelSsl option again in ffb92c7. TLS to Sentinel nodes isn't supported by the Python backend either, so adding it only on the WebSocket side would diverge from it. This PR keeps parity (TLS to the resolved master via ssl, plaintext sentinels), and TLS to sentinel nodes will follow in a separate feat PR covering both sides.

@madhushreeag madhushreeag left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 👍

@villebro
villebro merged commit 1aaabd8 into apache:master Oct 16, 2026
67 checks passed
@villebro
villebro deleted the villebro/websocket-redis-modes branch October 16, 2026 04:14
villebro added a commit that referenced this pull request Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants