From 0aee2ceb3ca2b26e5271f357b68deca912668f89 Mon Sep 17 00:00:00 2001 From: Dougal Matthews Date: Mon, 28 Nov 2016 12:35:09 +0000 Subject: [PATCH] Convert exceptions to strings when passing them to the Result class The Mistral Result class expects the error property to be either a string or a dict. Other types, like exceptions, can cause errors in mistral which in turn cause a critical failure. See the Mistral bug report: https://bugs.launchpad.net/mistral/+bug/1645295 This change also updates one use of the Result class that doesn't use kwargs. Change-Id: Ia93f298e5181bae92d7a08468d33c255d38b996a Closes-Bug: #1645296 --- tripleo_common/actions/baremetal.py | 5 +++-- tripleo_common/actions/parameters.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tripleo_common/actions/baremetal.py b/tripleo_common/actions/baremetal.py index 423f144e7..21dbd58af 100644 --- a/tripleo_common/actions/baremetal.py +++ b/tripleo_common/actions/baremetal.py @@ -17,6 +17,7 @@ import logging import ironic_inspector_client from mistral.workflow import utils as mistral_workflow_utils from oslo_utils import units +import six from tripleo_common.actions import base from tripleo_common import exception @@ -67,7 +68,7 @@ class RegisterOrUpdateNodes(base.TripleOAction): ramdisk_name=self.ramdisk_name) except Exception as err: LOG.exception("Error registering nodes with ironic.") - return mistral_workflow_utils.Result(error=err) + return mistral_workflow_utils.Result(error=six.text_type(err)) class ConfigureBootAction(base.TripleOAction): @@ -130,7 +131,7 @@ class ConfigureBootAction(base.TripleOAction): LOG.debug("Configuring boot option for Node %s", self.node_uuid) except Exception as err: LOG.exception("Error configuring node boot options with Ironic.") - return mistral_workflow_utils.Result(error=err) + return mistral_workflow_utils.Result(error=six.text_type(err)) class ConfigureRootDeviceAction(base.TripleOAction): diff --git a/tripleo_common/actions/parameters.py b/tripleo_common/actions/parameters.py index cab32061d..c9bcdf775 100644 --- a/tripleo_common/actions/parameters.py +++ b/tripleo_common/actions/parameters.py @@ -153,7 +153,7 @@ class GeneratePasswordsAction(base.TripleOAction): except Exception: msg = "Error retrieving mistral environment: %s" % self.container LOG.exception(msg) - return mistral_workflow_utils.Result("", msg) + return mistral_workflow_utils.Result(error=msg) try: stack_env = orchestration.stacks.environment(