Fix upgrade-charm hook that was only partly run

upgrade-charm bash script was only executed and the hook
from rabbitmq_server_relations.py was silently ignored
This corrects at the same time a failure in the hook if
rabbitmq deployment was from a single unit without any
cluster.

Closes-Bug: #1993100
Change-Id: Iaf88d18d26a1cde23397a097fcd98b09a0a98846
This commit is contained in:
Olivier Dufour-Cuvillier 2022-10-25 11:53:16 +09:00 committed by Nobuto Murata
parent 0ef5451292
commit 2c1074e49f
1 changed files with 4 additions and 2 deletions

View File

@ -777,7 +777,7 @@ def update_nrpe_checks():
rabbit.remove_nrpe_files()
@hooks.hook('upgrade-charm')
@hooks.hook('upgrade-charm.real')
@harden()
def upgrade_charm():
pre_install_hooks()
@ -803,7 +803,9 @@ def upgrade_charm():
shutil.move(old, new)
rabbit.update_peer_cluster_status()
if not rabbit.clustered_with_leader():
# this should be run only when rabbitmq is not a single unit and
# being really part of a cluster
if not rabbit.clustered_with_leader() and config('min-cluster-size'):
serial = coordinator.Serial()
log("Requesting cluster join lock")
serial.acquire(rabbit.COORD_KEY_CLUSTER)