Skip to content

Lock rabbitmq Erlang node name to a stable hostname (zulip + stoat)#26

Merged
wnstfy merged 1 commit into
mainfrom
fix/rabbitmq-hostname-stability
May 21, 2026
Merged

Lock rabbitmq Erlang node name to a stable hostname (zulip + stoat)#26
wnstfy merged 1 commit into
mainfrom
fix/rabbitmq-hostname-stability

Conversation

@wnstfy

@wnstfy wnstfy commented May 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Both zulip/docker-compose.yml and stoat/docker-compose.yml had a latent data-loss bug: their rabbitmq service didn't set hostname: or RABBITMQ_NODENAME. RabbitMQ stores its Mnesia DB under mnesia/rabbit@<container-hostname>/, and any container recreation (image bump, env change, manual --force-recreate) got a new random hostname → broker started as a fresh "virgin node" → vhosts / users / durable queues / persistent messages all became inaccessible (data was still on disk but orphaned).

Fix: set hostname: rabbitmq (zulip) and hostname: rabbit (stoat — matches the service key naming used in that compose file).

Verification (per the internal upgrade-testing methodology)

Tested in /tmp/upgrade-tests/rmq-hostname-fix/ with a compose matching the production hardening (cap_drop: ALL, user: 100:101, ipc: private, tmpfs, security_opt: no-new-privileges, RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS):

Check Result
Container hostname inside container rabbitmq (matches the hostname: directive)
Erlang node name rabbit@rabbitmq (stable)
Pre-recreate seed (vhost + user tag) present
After docker compose up -d --force-recreate container healthy
Post-recreate node name still rabbit@rabbitmq
Post-recreate vhost list upgrade_test_vhost preserved
Post-recreate user tag administrator preserved
Mnesia dir layout only rabbit@rabbitmq/ (no orphaned random-hostname dirs)
Error / fatal / panic / virgin-node log scan 0 matches

Migration for existing deployers

Anyone with a running deployment of zulip or stoat from this repo needs to rename their existing Mnesia node directory before the next container restart, otherwise the new container with the stable hostname will start fresh and the existing vhosts / users / queues will be unreachable. CHANGELOG documents the exact rename procedure. Fresh deployments are unaffected.

Test plan

  • scan, misconfig informational checks pass.
  • After merge, the queued rabbitmq 4.3.0-alpine Renovate PR can be merged safely (verified earlier in this session).

RabbitMQ namespaces its Mnesia data dir by Erlang node name —
mnesia/rabbit@<container-hostname>/. Neither zulip nor stoat
previously set `hostname:` on the rabbitmq service, so any
container recreation (image bump, env change, manual
--force-recreate) got a new random hostname and started as a
"virgin node", orphaning the old node's data on disk and
making vhosts / users / durable queues / persistent messages
inaccessible.

Fix: set `hostname: rabbitmq` (zulip) and `hostname: rabbit`
(stoat — matches the service key), matching each project's
existing service-name convention.

Verified end-to-end in an isolated /tmp test that matches the
production hardening (cap_drop ALL, user: 100:101, ipc: private,
tmpfs, security_opt, RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS):
- Container hostname resolves to the configured string.
- Erlang node name is rabbit@<configured-hostname>.
- After `docker compose up -d --force-recreate`: vhost and user
  tag preserved; node name unchanged; Mnesia dir contains only
  rabbit@<stable>/ (no orphaned random-hostname dirs).
- Zero error / fatal / panic / "virgin node" lines in logs.

CHANGELOG documents the migration step required for existing
deployers (rename the on-disk Mnesia subdirs). Fresh deployments
are unaffected.
@wnstfy
wnstfy enabled auto-merge (squash) May 21, 2026 12:50
@github-actions

Copy link
Copy Markdown
Contributor

Trivy misconfiguration findings (HIGH + CRITICAL)

✅ No HIGH or CRITICAL misconfigurations detected.

@github-actions

Copy link
Copy Markdown
Contributor

CVE delta

No changes. Every image's CVE set is identical to the previous scan.

@wnstfy
wnstfy merged commit 4a7fef2 into main May 21, 2026
4 checks passed
@wnstfy
wnstfy deleted the fix/rabbitmq-hostname-stability branch May 21, 2026 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant