fix: update Phoenix.PubSub.Redis configuration for 3.1.0 compatibility (#197)
The recent dependency update to phoenix_pubsub_redis 3.1.0 introduced
breaking changes in the configuration API. The new version no longer
accepts connection options at the top level - they must be nested in
:redis_opts.
Changes:
- Move Redix connection options into :redis_opts keyword list
- Keep only :node_name at top level per v3.1.0 requirements
- Maintains all resilience settings (timeouts, backoff, keepalive)
Before (invalid for v3.1.0):
[node_name: node(), host: "...", port: 6379, timeout: 5000, ...]
After (valid for v3.1.0):
[node_name: node(), redis_opts: [host: "...", port: 6379, timeout: 5000, ...]]
This fixes the production crash with error:
NimbleOptions.ValidationError: unknown options [:timeout, :backoff_initial,
:backoff_max, :exit_on_disconnection, :sync_connect]
Related: commit 0399b30d (Update Elixir dependencies)
Reviewed-on: graham/towerops-web#197
This commit is contained in:
parent
39039a4455
commit
cd6603873a
3 changed files with 29 additions and 21 deletions
|
|
@ -1,3 +1,14 @@
|
||||||
|
2026-03-27
|
||||||
|
fix: update Phoenix.PubSub.Redis configuration for 3.1.0 compatibility
|
||||||
|
- Fixed NimbleOptions.ValidationError crash on production pod startup
|
||||||
|
- Updated redis_pubsub_config/0 to use new phoenix_pubsub_redis 3.1.0 API structure
|
||||||
|
- Moved connection options (timeout, backoff_*, exit_on_disconnection, sync_connect, socket_opts) into :redis_opts keyword
|
||||||
|
- Top-level options now only :node_name and :redis_opts per v3.1.0 requirements
|
||||||
|
- Caused by recent dependency update to phoenix_pubsub_redis 3.1.0 (commit 0399b30d)
|
||||||
|
- Breaking change: v3.1.0 changed valid options from [:timeout, :backoff_initial, :backoff_max, :exit_on_disconnection, :sync_connect]
|
||||||
|
to [:node_name, :redis_pool_size, :compression_level, :redis_opts]
|
||||||
|
Files: lib/towerops/application.ex (redis_pubsub_config/0)
|
||||||
|
|
||||||
2026-03-27
|
2026-03-27
|
||||||
fix: handle alert_changed message in DashboardLive
|
fix: handle alert_changed message in DashboardLive
|
||||||
- Fixed FunctionClauseError when DashboardLive receives {:alert_changed, org_id} message
|
- Fixed FunctionClauseError when DashboardLive receives {:alert_changed, org_id} message
|
||||||
|
|
|
||||||
|
|
@ -245,28 +245,12 @@ defmodule Towerops.Application do
|
||||||
defp redis_pubsub_config do
|
defp redis_pubsub_config do
|
||||||
redis_config = Application.get_env(:towerops, :redis, [])
|
redis_config = Application.get_env(:towerops, :redis, [])
|
||||||
|
|
||||||
# Base configuration for Phoenix.PubSub.Redis
|
# Build Redix connection options (phoenix_pubsub_redis 3.1.0+ requires :redis_opts key)
|
||||||
base_opts = [
|
redis_opts = [
|
||||||
host: Keyword.get(redis_config, :host, "localhost"),
|
host: Keyword.get(redis_config, :host, "localhost"),
|
||||||
port: Keyword.get(redis_config, :port, 6379),
|
port: Keyword.get(redis_config, :port, 6379),
|
||||||
node_name: node()
|
# TCP keepalive to detect dead connections
|
||||||
]
|
socket_opts: [keepalive: true],
|
||||||
|
|
||||||
# Add password if configured (read from application config set by runtime.exs)
|
|
||||||
base_opts =
|
|
||||||
case Keyword.get(redis_config, :password) do
|
|
||||||
nil -> base_opts
|
|
||||||
"" -> base_opts
|
|
||||||
password -> Keyword.put(base_opts, :password, password)
|
|
||||||
end
|
|
||||||
|
|
||||||
# Add resilience options for better reconnection handling
|
|
||||||
resilience_opts = [
|
|
||||||
# Redix connection options for better resilience
|
|
||||||
socket_opts: [
|
|
||||||
# TCP keepalive to detect dead connections
|
|
||||||
keepalive: true
|
|
||||||
],
|
|
||||||
# Connection timeout (5 seconds)
|
# Connection timeout (5 seconds)
|
||||||
timeout: 5_000,
|
timeout: 5_000,
|
||||||
# Backoff settings for reconnection
|
# Backoff settings for reconnection
|
||||||
|
|
@ -278,7 +262,19 @@ defmodule Towerops.Application do
|
||||||
sync_connect: false
|
sync_connect: false
|
||||||
]
|
]
|
||||||
|
|
||||||
Keyword.merge(base_opts, resilience_opts)
|
# Add password if configured (read from application config set by runtime.exs)
|
||||||
|
redis_opts =
|
||||||
|
case Keyword.get(redis_config, :password) do
|
||||||
|
nil -> redis_opts
|
||||||
|
"" -> redis_opts
|
||||||
|
password -> Keyword.put(redis_opts, :password, password)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Phoenix.PubSub.Redis 3.1.0+ configuration structure
|
||||||
|
[
|
||||||
|
node_name: node(),
|
||||||
|
redis_opts: redis_opts
|
||||||
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
# Register file logger backend for development (only available in :dev environment)
|
# Register file logger backend for development (only available in :dev environment)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
2026-03-27 — Stability Improvements
|
2026-03-27 — Stability Improvements
|
||||||
|
* Fixed production deployment crash related to real-time messaging infrastructure
|
||||||
* Fixed dashboard crashes when alerts change
|
* Fixed dashboard crashes when alerts change
|
||||||
* Improved real-time alert updates reliability
|
* Improved real-time alert updates reliability
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue