From 3de62513161efbb0b1ea831628bff15764086a59 Mon Sep 17 00:00:00 2001 From: Alex Kavanagh Date: Tue, 5 May 2020 15:07:44 +0100 Subject: [PATCH] Fix broken code and collect errors on ceph commands --- zaza/openstack/charm_tests/ceph/mon/tests.py | 16 ++++++++++++---- zaza/openstack/utilities/exceptions.py | 6 ++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/zaza/openstack/charm_tests/ceph/mon/tests.py b/zaza/openstack/charm_tests/ceph/mon/tests.py index 276ed9f..0fea084 100644 --- a/zaza/openstack/charm_tests/ceph/mon/tests.py +++ b/zaza/openstack/charm_tests/ceph/mon/tests.py @@ -22,6 +22,7 @@ import zaza.model from zaza.openstack.utilities import ( generic as generic_utils, openstack as openstack_utils, + exceptions as zaza_exceptions ) import zaza.openstack.charm_tests.test_utils as test_utils @@ -43,7 +44,7 @@ class CinderCephMonTest(test_utils.OpenStackBaseTest): current_release = openstack_utils.get_os_release() bionic_train = openstack_utils.get_os_release('bionic_train') if current_release < bionic_train: - units.extend(zaza.model.get_utils("cinder-ceph", + units.extend(zaza.model.get_units("cinder-ceph", model_name=self.model_name)) commands = [ @@ -64,7 +65,14 @@ def run_commands(unit_name, commands): Apply context to commands until all variables have been replaced, then run the command on the given unit. """ + errors = [] for cmd in commands: - generic_utils.assertRemoteRunOK(zaza.model.run_on_unit( - unit_name, - cmd)) + try: + generic_utils.assertRemoteRunOK(zaza.model.run_on_unit( + unit_name, + cmd)) + except Exception as e: + errors.append("unit: {}, command: {}, error: {}" + .format(unit_name, cmd, str(e))) + if errors: + raise zaza_exceptions.CephGenericError("\n".join(errors)) diff --git a/zaza/openstack/utilities/exceptions.py b/zaza/openstack/utilities/exceptions.py index e9e5d23..f8673a1 100644 --- a/zaza/openstack/utilities/exceptions.py +++ b/zaza/openstack/utilities/exceptions.py @@ -168,6 +168,12 @@ class CephPoolNotConfigured(Exception): pass +class CephGenericError(Exception): + """A generic/other Ceph error occurred.""" + + pass + + class NovaGuestMigrationFailed(Exception): """Nova guest migration failed."""