diff --git a/sahara/plugins/general/exceptions.py b/sahara/plugins/general/exceptions.py index 5cc03124..ee9e17d5 100644 --- a/sahara/plugins/general/exceptions.py +++ b/sahara/plugins/general/exceptions.py @@ -23,6 +23,15 @@ class NodeGroupCannotBeScaled(e.SaharaException): self.code = "NODE_GROUP_CANNOT_BE_SCALED" +class DecommissionError(e.SaharaException): + code = "DECOMMISSION_ERROR" + message = "Failed to decommission cluster" + + def __init__(self, message): + if message: + self.message = message + + class ClusterCannotBeScaled(e.SaharaException): def __init__(self, cluster_name, reason): self.message = ("Cluster %s cannot be scaled : " diff --git a/sahara/plugins/vanilla/v1_2_1/scaling.py b/sahara/plugins/vanilla/v1_2_1/scaling.py index ab88d4e2..3d789cfb 100644 --- a/sahara/plugins/vanilla/v1_2_1/scaling.py +++ b/sahara/plugins/vanilla/v1_2_1/scaling.py @@ -19,6 +19,7 @@ import six from sahara import context from sahara.openstack.common import timeutils +from sahara.plugins.general import exceptions as ex from sahara.plugins.general import utils from sahara.plugins.vanilla.v1_2_1 import config_helper from sahara.plugins.vanilla.v1_2_1 import run_scripts as run @@ -73,8 +74,9 @@ def decommission_dn(nn, inst_to_be_deleted, survived_inst): context.sleep(3) if not all_found: - raise Exception("Cannot finish decommission in %s seconds" % - timeout) + ex.DecommissionError( + "Cannot finish decommission of cluster %s in %d seconds" % + (nn.node_group.cluster, timeout)) def parse_dfs_report(cmd_output): diff --git a/sahara/plugins/vanilla/v2_3_0/scaling.py b/sahara/plugins/vanilla/v2_3_0/scaling.py index 8cddc7a0..8cb5fda8 100644 --- a/sahara/plugins/vanilla/v2_3_0/scaling.py +++ b/sahara/plugins/vanilla/v2_3_0/scaling.py @@ -14,8 +14,8 @@ # limitations under the License. from sahara import context -from sahara import exceptions as ex from sahara.openstack.common import timeutils +from sahara.plugins.general import exceptions as ex from sahara.plugins.general import utils as u from sahara.plugins.vanilla.v2_3_0 import config from sahara.plugins.vanilla.v2_3_0 import run_scripts as run @@ -115,8 +115,9 @@ def _check_decommission(cluster, instances, check_func, timeout): else: context.sleep(5) else: - ex.SaharaException("Cannot finish decommission in %d seconds" % - timeout) + ex.DecommissionError( + "Cannot finish decommission of cluster %s in %d seconds" % + (cluster, timeout)) def _check_nodemanagers_decommission(cluster, instances):