tweaks

6670896 · gmorell · 2026-05-21 13:47

2 files +29 -32

Files changed

modified rel/env.sh.eex
+29 −32
@@ -1,39 +1,36 @@
1 1 #!/bin/sh
2 −# Sourced by every `bin/waxx <command>` invocation. Only `start` and
3 −# `daemon` need long-name distribution — they're the long-lived
4 −# server nodes peer pods talk to. `remote`, `eval`, and `rpc` use
5 −# unique auto-generated short names so they don't fight the running
6 −# server for the `waxx@<pod-ip>` slot in epmd. Setting RELEASE_NODE for
7 −# those would cause an epmd name collision: the new (short-lived)
8 −# BEAM registers under the same name, evicts the running server from
9 −# epmd, and now peer pods can't find it via dist any more — which
10 −# typically takes the running pod down on its next inbound connect.
2 +# Sourced by every `bin/waxx <command>` invocation. We always set
3 +# `RELEASE_NODE` when `POD_IP` is available because *every* subcommand
4 +# needs to know the running release's node name:
5 +#
6 +# - `start` / `daemon` register the running server under this name.
7 +# - `remote` / `eval` / `rpc` pass it to `-remsh` (or RPC dial) to
8 +# attach to the running server. The temporary BEAM those commands
9 +# spawn picks its OWN unique short name (`rem-<rand>@<host>`),
10 +# so setting RELEASE_NODE here does not cause an epmd collision —
11 +# it only tells the temporary BEAM which target to talk to.
12 +#
13 +# Only `start` / `daemon` get the dist port pinned, since the
14 +# temporary BEAMs for remote/eval/rpc only make outbound connections
15 +# and don't need their own listener at a known port.
11 16 #
12 17 # POD_IP comes from the deployment's downward API. RELEASE_COOKIE
13 −# comes from the elixir-args / waxx-secrets secret so every replica
14 −# agrees on the Erlang cookie.
18 +# comes from the waxx-secrets Secret so every replica agrees on the
19 +# Erlang cookie.
20 +
21 +if [ -n "${POD_IP:-}" ]; then
22 + export RELEASE_DISTRIBUTION=name
23 + export RELEASE_NODE="waxx@${POD_IP}"
24 +else
25 + echo "[env.sh] POD_IP is empty — falling back to default short-name distribution" >&2
26 +fi
27 +
15 28 case ${RELEASE_COMMAND:-} in
16 29 start*|daemon*)
17 − if [ -n "${POD_IP:-}" ]; then
18 − echo "[env.sh] starting with name distribution as waxx@${POD_IP}" >&2
19 − export RELEASE_DISTRIBUTION=name
20 − export RELEASE_NODE="waxx@${POD_IP}"
21 −
22 − # Pin the inet_dist listener to a known port so it's predictable
23 − # from peers and routable through any future NetworkPolicy.
24 − # Without this BEAM picks a random ephemeral port each boot,
25 − # which works under default k8s pod-to-pod TCP but breaks the
26 − # moment a policy locks the namespace down.
27 − export ELIXIR_ERL_OPTIONS="${ELIXIR_ERL_OPTIONS:-} -kernel inet_dist_listen_min 9100 inet_dist_listen_max 9100"
28 − else
29 − echo "[env.sh] POD_IP is empty — falling back to local-only sname distribution" >&2
30 − fi
31 − ;;
32 − *)
33 − # remote / eval / rpc — let mix release auto-pick a unique short
34 − # name (`rem-<rand>@127.0.0.1`) and use `-remsh` to attach by the
35 − # running node's long name (which it reads from this same script's
36 − # state under start, baked into the release at build).
37 − :
30 + echo "[env.sh] starting with name distribution as ${RELEASE_NODE:-(unset)}" >&2
31 + # Pin the inet_dist listener so the port is predictable from peers
32 + # and matches the headless service / any future NetworkPolicy.
33 + # Without this BEAM picks a random ephemeral port each boot.
34 + export ELIXIR_ERL_OPTIONS="${ELIXIR_ERL_OPTIONS:-} -kernel inet_dist_listen_min 9100 inet_dist_listen_max 9100"
38 35 ;;
39 36 esac

Parents: ffe9912