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
This commit is contained in:
parent
1304ff838c
commit
7a05679ebc
|
@ -879,6 +879,20 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
||||||
'/fake/path', mock.ANY, mock.ANY, mock.ANY,
|
'/fake/path', mock.ANY, mock.ANY, 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',
|
@mock.patch('tripleoclient.utils.create_tempest_deployer_input',
|
||||||
autospec=True)
|
autospec=True)
|
||||||
@mock.patch('tripleoclient.utils.create_overcloudrc', autospec=True)
|
@mock.patch('tripleoclient.utils.create_overcloudrc', autospec=True)
|
||||||
|
|
|
@ -397,18 +397,17 @@ class DeployOvercloud(command.Command):
|
||||||
def _try_overcloud_deploy_with_compat_yaml(self, tht_root, stack,
|
def _try_overcloud_deploy_with_compat_yaml(self, tht_root, stack,
|
||||||
stack_name, parameters,
|
stack_name, parameters,
|
||||||
environments, timeout):
|
environments, timeout):
|
||||||
|
messages = ['The following errors occurred:']
|
||||||
for overcloud_yaml_name in constants.OVERCLOUD_YAML_NAMES:
|
for overcloud_yaml_name in constants.OVERCLOUD_YAML_NAMES:
|
||||||
overcloud_yaml = os.path.join(tht_root, overcloud_yaml_name)
|
overcloud_yaml = os.path.join(tht_root, overcloud_yaml_name)
|
||||||
try:
|
try:
|
||||||
self._heat_deploy(stack, stack_name, overcloud_yaml,
|
self._heat_deploy(stack, stack_name, overcloud_yaml,
|
||||||
parameters, environments, timeout)
|
parameters, environments, timeout)
|
||||||
except six.moves.urllib.error.URLError:
|
except six.moves.urllib.error.URLError as e:
|
||||||
pass
|
messages.append(str(e.reason))
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
message = "The files {0} not found in the {1} directory".format(
|
raise ValueError('\n'.join(messages))
|
||||||
constants.OVERCLOUD_YAML_NAMES, tht_root)
|
|
||||||
raise ValueError(message)
|
|
||||||
|
|
||||||
def _is_tls_enabled(self, overcloud_endpoint):
|
def _is_tls_enabled(self, overcloud_endpoint):
|
||||||
return overcloud_endpoint.startswith('https')
|
return overcloud_endpoint.startswith('https')
|
||||||
|
|
Loading…
Reference in New Issue