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
(cherry picked from commit 7a05679ebc
)
This commit is contained in:
parent
9559dc59f4
commit
55ccfeac34
|
@ -886,6 +886,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)
|
||||
|
|
|
@ -402,18 +402,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')
|
||||
|
|
Loading…
Reference in New Issue