Fix return code when failing before launching the stack

Until now when a configuration error was detected early during the
pre-deployment verifications, the command would correctly return before
attempting to create/update the Heat stack, however the return code
would still show as '0', preventing scripts from picking up the
problem.

Change-Id: I8bd16e9753618e4c234440d7a6626e0ce4bd9972
Closes-Bug: #1672790
This commit is contained in:
Julie Pichon 2017-03-16 11:09:00 +00:00
parent cacaea1c93
commit 28051613c9
3 changed files with 34 additions and 2 deletions

View File

@ -0,0 +1,7 @@
---
fixes:
- |
`overcloud deploy` correctly returns an error code when failing
during the pre-deployment verifications (before the stack is
launched) (`bug 1672790
<https://bugs.launchpad.net/tripleo/+bug/1672790>`__).

View File

@ -1328,3 +1328,28 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
self.cmd.take_action(parsed_args)
self.assertTrue(self.cmd._predeploy_verify_capabilities.called)
@mock.patch('tripleoclient.utils.get_overcloud_endpoint', autospec=True)
@mock.patch('tripleoclient.utils.write_overcloudrc', autospec=True)
@mock.patch('tripleoclient.workflows.deployment.overcloudrc',
autospec=True)
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
'_deploy_tripleo_heat_templates_tmpdir', autospec=True)
def test_validations_failure_raises_exception(
self, mock_deploy_tmpdir,
mock_overcloudrc, mock_write_overcloudrc,
mock_overcloud_endpoint):
clients = self.app.client_manager
orchestration_client = clients.orchestration
orchestration_client.stacks.get.return_value = mock.Mock()
self.cmd._predeploy_verify_capabilities = mock.Mock(
return_value=(1, 0))
arglist = ['--templates']
verifylist = [
('templates', '/usr/share/openstack-tripleo-heat-templates/'),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.assertRaises(exceptions.InvalidConfiguration,
self.cmd.take_action, parsed_args)

View File

@ -1097,14 +1097,14 @@ class DeployOvercloud(command.Command):
errors)
if parsed_args.validation_warnings_fatal or \
parsed_args.validation_errors_fatal:
return
raise exceptions.InvalidConfiguration()
if warnings > 0:
self.log.error(
"Configuration has %d warnings, fix them before "
"proceeding.",
warnings)
if parsed_args.validation_warnings_fatal:
return
raise exceptions.InvalidConfiguration()
else:
self.log.info("SUCCESS: No warnings or errors in deploy "
"configuration, proceeding.")