From dc2f29ac9ba18f672964d25862fe7cd4907af36e Mon Sep 17 00:00:00 2001 From: Damien Ciabrini Date: Thu, 4 Apr 2019 09:04:08 +0200 Subject: [PATCH] [Queens-only] Ensure epmd is spawned by systemd before redeploy On (re)deploy, we forcibly restart epmd and rabbit to ensure any upgrade of erlang or rabbitmq can be taken into account before puppet runs. But there is currently no guarantee as to which one of systemd or rabbitmq will restart epmd. This is an improvement over I6f486b0b70f19d8b4916ef500675c0739939e060, to selectively kill epmd and ensure the systemd service will always restart it, like it is supposed to. Change-Id: I82b419cfe4585a3f185687b8cc0a19bb534f7536 Closes-Bug: #1823003 --- .../configure.d/40-stop-running-epmd | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/elements/undercloud-install/os-refresh-config/configure.d/40-stop-running-epmd b/elements/undercloud-install/os-refresh-config/configure.d/40-stop-running-epmd index 991aef4b4..4383ecb36 100755 --- a/elements/undercloud-install/os-refresh-config/configure.d/40-stop-running-epmd +++ b/elements/undercloud-install/os-refresh-config/configure.d/40-stop-running-epmd @@ -6,14 +6,30 @@ set -eux # # To start undercloud deployment from a known state, restart any # running epmd/rabbitmq processes here. epmd can be started by either -# systemd or rabbitmq, so try not to special-case it and kill the -# processes we find. Restarting rabbitmq will restart epmd -# automatically. +# systemd or rabbitmq, so try to kill all the relevant processes. +# Restarting rabbitmq will restart epmd automatically. # # Note: this has to run before 50-puppet-stack-config, i.e. before # any puppet/facter call to rabbitmq. -for pid in $(pgrep epmd); do kill $pid; done +RESTART_RABBITMQ= + +# If RabbitMQ is running, stop it and try to stop the epmd process +# it may have spawned if systemctl is-active rabbitmq-server; then - systemctl restart rabbitmq-server + RESTART_RABBITMQ=yes + systemctl stop rabbitmq-server + pgrep -u rabbitmq -f 'epmd.*-daemon' | xargs -r kill +fi + +# If epmd was started by systemd, restart it now to give it a +# chance to use the up-to-date Erlang runtime on the system. +# Since no epmd from RabbitMQ is running at this point, the +# epmd start by systemd should succeed in binding to the +# listen address and service should always start +systemctl try-restart epmd@* + +# If we stopped RabbitMQ earlier, restart it now +if [ -n "$RESTART_RABBITMQ" ]; then + systemctl start rabbitmq-server fi