From 778d36e1fa958e358ca378d2b6f3b759f81e05af Mon Sep 17 00:00:00 2001 From: Liam Young Date: Thu, 8 Sep 2022 05:49:15 +0000 Subject: [PATCH 1/3] 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): From f3724b22812b442c5b0d1badd8086401fea6f054 Mon Sep 17 00:00:00 2001 From: Liam Young Date: Thu, 8 Sep 2022 08:21:21 +0000 Subject: [PATCH 2/3] Add additional logging --- zaza/openstack/charm_tests/manila_ganesha/tests.py | 1 + 1 file changed, 1 insertion(+) diff --git a/zaza/openstack/charm_tests/manila_ganesha/tests.py b/zaza/openstack/charm_tests/manila_ganesha/tests.py index 9198e72..9622f67 100644 --- a/zaza/openstack/charm_tests/manila_ganesha/tests.py +++ b/zaza/openstack/charm_tests/manila_ganesha/tests.py @@ -50,6 +50,7 @@ class ManilaGaneshaTests(manila_tests.ManilaBaseTest): ganeshas = [ app for app in zaza.model.sync_deployed() if 'ganesha' in app and 'mysql' not in app] + logging.info('Found ganeshas: {}'.format(ganeshas)) for ganesha in ganeshas: ganesha_unit = zaza.model.get_units(ganesha)[0] hacluster_unit = zaza_utils_juju.get_subordinate_units( From 33a6408c839cd82a9a3894e79e1b55782695d44b Mon Sep 17 00:00:00 2001 From: Liam Young Date: Thu, 8 Sep 2022 12:55:04 +0000 Subject: [PATCH 3/3] Set and log model name --- zaza/openstack/charm_tests/manila_ganesha/tests.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/zaza/openstack/charm_tests/manila_ganesha/tests.py b/zaza/openstack/charm_tests/manila_ganesha/tests.py index 9622f67..158fb1a 100644 --- a/zaza/openstack/charm_tests/manila_ganesha/tests.py +++ b/zaza/openstack/charm_tests/manila_ganesha/tests.py @@ -48,9 +48,11 @@ class ManilaGaneshaTests(manila_tests.ManilaBaseTest): # this is a best-guestimate arrived at by looking for applications # with the word 'ganesha' in their names. ganeshas = [ - app for app in zaza.model.sync_deployed() + app for app in zaza.model.sync_deployed(model_name=self.model_name) if 'ganesha' in app and 'mysql' not in app] - logging.info('Found ganeshas: {}'.format(ganeshas)) + logging.info('Found ganeshas in model {}: {}'.format( + self.model_name, + ganeshas)) for ganesha in ganeshas: ganesha_unit = zaza.model.get_units(ganesha)[0] hacluster_unit = zaza_utils_juju.get_subordinate_units(