processone / ejabberd

Robust, Ubiquitous and Massively Scalable Messaging Platform (XMPP, MQTT, SIP Server)
https://www.process-one.net/en/ejabberd/
Other
6k stars 1.5k forks source link

erts_vsn inside ejabberdctl never gets set #4194

Closed GautaA closed 2 months ago

GautaA commented 3 months ago

Environment

Bug description

I'm not sure if this is a bug or not, but I have noticed that inside ejabberdctl script on all of our deployments only the erts_vsn variable never gets set. This usually wouldn't be the problem, but we're trying to manage ejabberdctl ourselves for now because of this issue and this is causing Ansible to throw AnsibleUndefinedVariable: 'erts_vsn' is undefined" errors.

Example how it looks:

# define default environment variables
[ -z "$SCRIPT" ] && SCRIPT=$0
SCRIPT_DIR="$(cd "$(dirname "$SCRIPT")" && pwd -P)"
# shellcheck disable=SC2034
ERTS_VSN="{{erts_vsn}}"
ERL="/usr/bin/erl"
IEX="/opt/ejabberd/bin/iex"
EPMD="/usr/bin/epmd"
INSTALLUSER=""

Does anyone know why this is happening and what's erts_vsn used for?

badlop commented 2 months ago

That variable was added in 94a733c6669afb7b41fdafcb9bf0a4ac24a483f2. The variable is set and used when building an OTP release; but it is useless when using other install methods.

If ejabberd is built into an OTP release with:

./configure --with-rebar=rebar3
# or ./configure --with-rebar=mix
make
make prod
# or make dev

then the file _build/prod/rel/ejabberd/bin/ejabberdctl contains:

ERTS_VSN="14.2.3"
ERL="${SCRIPT_DIR%/*}/erts-${ERTS_VSN#erts-}/bin/erl"
EPMD="${SCRIPT_DIR%/*}/erts-${ERTS_VSN#erts-}/bin/epmd"

This is also the case in the RUN, DEB and RPM binary installers from ProcessOne, as they use OTP release method. And the container images too.


However, when using make relive or make install or make install-rel, the file _build/relive/ejabberdctl (or $PREFIX/sbin/ejabberdctl) contains:

ERTS_VSN="{{erts_vsn}}"
ERL="/home/badlop/.asdf/shims/erl"
EPMD="/home/badlop/.asdf/shims/epmd"

How do you obtain that ejabberdctl script? Did you use make install?

In your script, as you can see, ERTS_VSN is not used, so it isn't a problem for the script that the variable isn't set. If there is another tool that detects this and complains, you could try to remove that variable definition.

GautaA commented 2 months ago

Hi! Thank you for a detailed explanation. I checked, and you were right, make install was used. We did remove the variable and everything works smoothly so far.

What do you think about omitting the variable if it doesn't get set by not building from the OTP? It's just a QOL, and not that important, but would clean up the ctl file a bit.

badlop commented 2 months ago

Right, it's easy in Makefile.in to comment that line when it isn't needed. It will be fixed in the next release.