From 7a05679ebc944e3bec6f20c194c40fae1cf39d8d Mon Sep 17 00:00:00 2001 From: James Slagle Date: Fri, 1 Apr 2016 08:57:41 -0400 Subject: [PATCH] Show correct missing files when an error occurs This function was swallowing all missing file exceptions, and then printing a message saying overcloud.yaml or overcloud-without-mergepy.yaml were not found. The problem is that the URLError could occur for any missing file, such as a missing environment file, typo in a relative patch or filename, etc. And in those cases, the error message is actually quite misleading, especially if the overcloud.yaml does exist at the exact shown path. This change makes it such that the actual missing file paths are shown in the output. Closes-Bug: 1584792 Change-Id: Id9a70cb50d7dfa3dde72eefe0a5eaea7985236ff --- .../v1/overcloud_deploy/test_overcloud_deploy.py | 14 ++++++++++++++ tripleoclient/v1/overcloud_deploy.py | 9 ++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/tripleoclient/tests/v1/overcloud_deploy/test_overcloud_deploy.py b/tripleoclient/tests/v1/overcloud_deploy/test_overcloud_deploy.py index 2d82c2ddf..494af980a 100644 --- a/tripleoclient/tests/v1/overcloud_deploy/test_overcloud_deploy.py +++ b/tripleoclient/tests/v1/overcloud_deploy/test_overcloud_deploy.py @@ -879,6 +879,20 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud): '/fake/path', mock.ANY, mock.ANY, mock.ANY, mock.ANY, mock.ANY) + @mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.' + '_heat_deploy', autospec=True) + def test_try_overcloud_deploy_show_missing_file( + self, mock_heat_deploy_func): + mock_heat_deploy_func.side_effect = [ + six.moves.urllib.error.URLError('/fake/path not found') + for stack_file in constants.OVERCLOUD_YAML_NAMES] + try: + self.cmd._try_overcloud_deploy_with_compat_yaml( + '/fake/path', mock.ANY, mock.ANY, mock.ANY, + mock.ANY, mock.ANY) + except ValueError as value_error: + self.assertIn('/fake/path', str(value_error)) + @mock.patch('tripleoclient.utils.create_tempest_deployer_input', autospec=True) @mock.patch('tripleoclient.utils.create_overcloudrc', autospec=True) diff --git a/tripleoclient/v1/overcloud_deploy.py b/tripleoclient/v1/overcloud_deploy.py index 862ca24fc..05353f5f6 100644 --- a/tripleoclient/v1/overcloud_deploy.py +++ b/tripleoclient/v1/overcloud_deploy.py @@ -397,18 +397,17 @@ class DeployOvercloud(command.Command): def _try_overcloud_deploy_with_compat_yaml(self, tht_root, stack, stack_name, parameters, environments, timeout): + messages = ['The following errors occurred:'] for overcloud_yaml_name in constants.OVERCLOUD_YAML_NAMES: overcloud_yaml = os.path.join(tht_root, overcloud_yaml_name) try: self._heat_deploy(stack, stack_name, overcloud_yaml, parameters, environments, timeout) - except six.moves.urllib.error.URLError: - pass + except six.moves.urllib.error.URLError as e: + messages.append(str(e.reason)) else: return - message = "The files {0} not found in the {1} directory".format( - constants.OVERCLOUD_YAML_NAMES, tht_root) - raise ValueError(message) + raise ValueError('\n'.join(messages)) def _is_tls_enabled(self, overcloud_endpoint): return overcloud_endpoint.startswith('https')