summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulie Pichon <jpichon@redhat.com>2017-03-16 11:09:00 +0000
committerJulie Pichon <jpichon@redhat.com>2017-06-19 09:29:15 +0000
commitbb361f47bf9bfad79af0c062fa1107386e769faa (patch)
tree5b08860e8cf6ff14287e39f07d76be2469b69618
parentd3e0ca5822c54de5f4d2e81e294cc1e1877e2921 (diff)
Fix return code when failing before launching the stackstable/newton
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. Conflicts: tripleoclient/tests/v1/overcloud_deploy/test_overcloud_deploy.py tripleoclient/v1/overcloud_deploy.py Change-Id: I8bd16e9753618e4c234440d7a6626e0ce4bd9972 Closes-Bug: #1672790 (cherry picked from commit 28051613c9c1c5231140981fca76fa704af55d5d)
Notes
Notes (review): Code-Review+2: Emilien Macchi <emilien@redhat.com> Workflow+1: Emilien Macchi <emilien@redhat.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Mon, 19 Jun 2017 14:36:43 +0000 Reviewed-on: https://review.openstack.org/473302 Project: openstack/python-tripleoclient Branch: refs/heads/stable/newton
-rw-r--r--releasenotes/notes/return-code-on-predeploy-failure-bd62025646e25433.yaml7
-rw-r--r--tripleoclient/tests/v1/overcloud_deploy/test_overcloud_deploy.py25
-rw-r--r--tripleoclient/v1/overcloud_deploy.py4
3 files changed, 34 insertions, 2 deletions
diff --git a/releasenotes/notes/return-code-on-predeploy-failure-bd62025646e25433.yaml b/releasenotes/notes/return-code-on-predeploy-failure-bd62025646e25433.yaml
new file mode 100644
index 0000000..8261145
--- /dev/null
+++ b/releasenotes/notes/return-code-on-predeploy-failure-bd62025646e25433.yaml
@@ -0,0 +1,7 @@
1---
2fixes:
3 - |
4 `overcloud deploy` correctly returns an error code when failing
5 during the pre-deployment verifications (before the stack is
6 launched) (`bug 1672790
7 <https://bugs.launchpad.net/tripleo/+bug/1672790>`__).
diff --git a/tripleoclient/tests/v1/overcloud_deploy/test_overcloud_deploy.py b/tripleoclient/tests/v1/overcloud_deploy/test_overcloud_deploy.py
index eae3978..202ba9c 100644
--- a/tripleoclient/tests/v1/overcloud_deploy/test_overcloud_deploy.py
+++ b/tripleoclient/tests/v1/overcloud_deploy/test_overcloud_deploy.py
@@ -1507,3 +1507,28 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
1507 {}, 1, '/tmp', {}, True) 1507 {}, 1, '/tmp', {}, True)
1508 1508
1509 self.assertFalse(mock_deploy_and_wait.called) 1509 self.assertFalse(mock_deploy_and_wait.called)
1510
1511 @mock.patch('tripleoclient.utils.get_overcloud_endpoint', autospec=True)
1512 @mock.patch('tripleoclient.utils.write_overcloudrc', autospec=True)
1513 @mock.patch('tripleoclient.workflows.deployment.overcloudrc',
1514 autospec=True)
1515 @mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
1516 '_deploy_tripleo_heat_templates_tmpdir', autospec=True)
1517 def test_validations_failure_raises_exception(
1518 self, mock_deploy_tmpdir,
1519 mock_overcloudrc, mock_write_overcloudrc,
1520 mock_overcloud_endpoint):
1521 clients = self.app.client_manager
1522 orchestration_client = clients.orchestration
1523 orchestration_client.stacks.get.return_value = mock.Mock()
1524 self.cmd._predeploy_verify_capabilities = mock.Mock(
1525 return_value=(1, 0))
1526
1527 arglist = ['--templates']
1528 verifylist = [
1529 ('templates', '/usr/share/openstack-tripleo-heat-templates/'),
1530 ]
1531 parsed_args = self.check_parser(self.cmd, arglist, verifylist)
1532
1533 self.assertRaises(exceptions.InvalidConfiguration,
1534 self.cmd.take_action, parsed_args)
diff --git a/tripleoclient/v1/overcloud_deploy.py b/tripleoclient/v1/overcloud_deploy.py
index 1eee852..277ab10 100644
--- a/tripleoclient/v1/overcloud_deploy.py
+++ b/tripleoclient/v1/overcloud_deploy.py
@@ -1140,13 +1140,13 @@ class DeployOvercloud(command.Command):
1140 errors) 1140 errors)
1141 if parsed_args.validation_warnings_fatal or \ 1141 if parsed_args.validation_warnings_fatal or \
1142 parsed_args.validation_errors_fatal: 1142 parsed_args.validation_errors_fatal:
1143 return 1143 raise exceptions.InvalidConfiguration()
1144 if warnings > 0: 1144 if warnings > 0:
1145 self.log.error( 1145 self.log.error(
1146 "Configuration has %d warnings, fix them before proceeding. ", 1146 "Configuration has %d warnings, fix them before proceeding. ",
1147 warnings) 1147 warnings)
1148 if parsed_args.validation_warnings_fatal: 1148 if parsed_args.validation_warnings_fatal:
1149 return 1149 raise exceptions.InvalidConfiguration()
1150 else: 1150 else:
1151 self.log.info("SUCCESS: No warnings or errors in deploy " 1151 self.log.info("SUCCESS: No warnings or errors in deploy "
1152 "configuration, proceeding.") 1152 "configuration, proceeding.")