From 778d36e1fa958e358ca378d2b6f3b759f81e05af Mon Sep 17 00:00:00 2001 From: Liam Young Date: Thu, 8 Sep 2022 05:49:15 +0000 Subject: [PATCH] Fix Ganesha _restart_share_instance for non-ha Manila Ganesha is not always deployed in an ha configuration in functional tests. This means there is no automated restart of the manila services but the _restart_share_instance method shuts down manila services via systemctl and expects them to be automatically started. This change detects if the hacluster charm is present, if it is it defaults it used the old behaviour otherwise systemctl is used to restart the services. --- .../charm_tests/manila_ganesha/tests.py | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/zaza/openstack/charm_tests/manila_ganesha/tests.py b/zaza/openstack/charm_tests/manila_ganesha/tests.py index 2b6fda4..9198e72 100644 --- a/zaza/openstack/charm_tests/manila_ganesha/tests.py +++ b/zaza/openstack/charm_tests/manila_ganesha/tests.py @@ -26,6 +26,7 @@ from zaza.openstack.charm_tests.manila_ganesha.setup import ( import zaza.openstack.utilities.generic as generic_utils import zaza.openstack.charm_tests.manila.tests as manila_tests import zaza.model +import zaza.utilities.juju as zaza_utils_juju class ManilaGaneshaTests(manila_tests.ManilaBaseTest): @@ -50,13 +51,27 @@ class ManilaGaneshaTests(manila_tests.ManilaBaseTest): app for app in zaza.model.sync_deployed() if 'ganesha' in app and 'mysql' not in app] for ganesha in ganeshas: + ganesha_unit = zaza.model.get_units(ganesha)[0] + hacluster_unit = zaza_utils_juju.get_subordinate_units( + [ganesha_unit.entity_id], + charm_name='hacluster') + logging.info('Ganesha in hacluster mode: {}'.format( + bool(hacluster_unit))) + for unit in zaza.model.get_units(ganesha): - # While we really only need to run this on the machine hosting - # nfs-ganesha and manila-share, running it everywhere isn't - # harmful. Pacemaker handles restarting the services - zaza.model.run_on_unit( - unit.entity_id, - "systemctl stop manila-share nfs-ganesha") + if hacluster_unit: + # While we really only need to run this on the machine + # hosting # nfs-ganesha and manila-share, running it + # everywhere isn't harmful. Pacemaker handles restarting + # the services + zaza.model.run_on_unit( + unit.entity_id, + "systemctl stop manila-share nfs-ganesha") + else: + zaza.model.run_on_unit( + unit.entity_id, + "systemctl restart manila-share nfs-ganesha") + return True def _run_nrpe_check_command(self, commands):