Only start the deploy if the Heat stack isn't already in progress

At the moment the deploy command will take a number of steps, including
updating the plan and setting parameters in Mistral. Then when it gets
to the deploy, the workflow will fail. This change stops it earlier in
the process, which will be quicker and cleaner.

Change-Id: I09e40e3f27b9ba3b0f3dad97cece6afbe28bd6b9
Partial-Bug: #1640249
This commit is contained in:
Dougal Matthews 2016-11-17 11:43:36 +00:00
parent 6ffe1ca57b
commit 7f16d10356
4 changed files with 32 additions and 6 deletions

View File

@ -33,6 +33,10 @@ class DeploymentError(RuntimeError):
"""Deployment failed"""
class StackInProgress(RuntimeError):
"""Unable to deploy as the stack is busy"""
class RootUserExecution(Exception):
"""Command was executed by a root user"""

View File

@ -28,6 +28,7 @@ FAKE_STACK = {
'CephStorageCount': 0,
},
'stack_name': 'overcloud',
'stack_status': "CREATE_COMPLETE",
'outputs': [{
'output_key': 'KeystoneURL',
'output_value': 'http://0.0.0.0:8000',

View File

@ -1483,12 +1483,12 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
@mock.patch('os.path.relpath', autospec=True)
@mock.patch('tripleo_common.update.add_breakpoints_cleanup_into_env',
autospec=True)
def test__heat_deploy_update_plan_only(self, mock_breakpoints_cleanup,
mock_relpath,
mock_get_template_contents,
mock_upload_missing_files,
mock_process_and_upload_env,
mock_deploy_and_wait):
def test_heat_deploy_update_plan_only(self, mock_breakpoints_cleanup,
mock_relpath,
mock_get_template_contents,
mock_upload_missing_files,
mock_process_and_upload_env,
mock_deploy_and_wait):
clients = self.app.client_manager
orchestration_client = clients.orchestration
mock_stack = fakes.create_tht_stack()
@ -1511,3 +1511,19 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
{}, 1, '/tmp', {}, True)
self.assertFalse(mock_deploy_and_wait.called)
def test_heat_stack_busy(self):
clients = self.app.client_manager
orchestration_client = clients.orchestration
mock_stack = fakes.create_tht_stack(stack_status="IN_PROGRESS")
orchestration_client.stacks.get.return_value = mock_stack
arglist = ['--templates', ]
verifylist = [
('templates', '/usr/share/openstack-tripleo-heat-templates/'),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.assertRaises(exceptions.StackInProgress,
self.cmd.take_action, parsed_args)

View File

@ -1136,6 +1136,11 @@ class DeployOvercloud(command.Command):
stack = utils.get_stack(orchestration_client, parsed_args.stack)
if stack and stack.stack_status == 'IN_PROGRESS':
raise exceptions.StackInProgress(
"Unable to deploy as the stack '{}' status is '{}'".format(
stack.stack_name, stack.stack_status))
parameters = self._update_parameters(
parsed_args, clients.network, stack)