[train-only] Store overcloud status locally
After undercloud upgrade, there maybe a need to check for the overcloud status. With mistral and swift dropped from the undercloud in wallaby, we need to store the status locally before upgrading undercloud. This is train-only as ussuri/victoria are already EOL. Resolves: rhbz#2093228 Change-Id: I1f00077b1e91a41da135e7abaa0a16d9f4b82e8c
This commit is contained in:
@@ -1413,8 +1413,8 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
||||
self.assertTrue(fixture.mock_config_download.called)
|
||||
self.assertTrue(fixture.mock_set_deployment_status.called)
|
||||
self.assertEqual(
|
||||
'deploying',
|
||||
fixture.mock_set_deployment_status.call_args[0][1])
|
||||
'DEPLOY_SUCCESS',
|
||||
fixture.mock_set_deployment_status.call_args[-1]['status'])
|
||||
mock_copy.assert_called_once()
|
||||
|
||||
@mock.patch('tripleoclient.utils.get_stack_output_item',
|
||||
@@ -1452,8 +1452,8 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
||||
self.assertTrue(fixture.mock_config_download.called)
|
||||
self.assertTrue(fixture.mock_set_deployment_status.called)
|
||||
self.assertEqual(
|
||||
'deploying',
|
||||
fixture.mock_set_deployment_status.call_args[0][1])
|
||||
'DEPLOY_SUCCESS',
|
||||
fixture.mock_set_deployment_status.call_args[-1]['status'])
|
||||
mock_copy.assert_called_once()
|
||||
|
||||
@mock.patch('tripleoclient.utils.get_stack_output_item',
|
||||
@@ -1501,8 +1501,8 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
||||
self.assertTrue(fixture.mock_config_download.called)
|
||||
self.assertTrue(fixture.mock_set_deployment_status.called)
|
||||
self.assertEqual(
|
||||
'failed',
|
||||
fixture.mock_set_deployment_status.call_args[0][1])
|
||||
'DEPLOY_FAILED',
|
||||
fixture.mock_set_deployment_status.call_args[-1]['status'])
|
||||
|
||||
@mock.patch('tripleoclient.utils.get_stack_output_item',
|
||||
autospec=True)
|
||||
|
||||
@@ -2011,6 +2011,32 @@ def ansible_symlink():
|
||||
run_command(cmd, name='ansible-playbook-3-symlink')
|
||||
|
||||
|
||||
def get_default_working_dir(stack):
|
||||
return os.path.join(
|
||||
os.path.expanduser('~'),
|
||||
"overcloud-deploy", stack)
|
||||
|
||||
|
||||
def get_status_yaml(stack_name, working_dir):
|
||||
status_yaml = os.path.join(
|
||||
working_dir,
|
||||
'%s-deployment_status.yaml' % stack_name)
|
||||
return status_yaml
|
||||
|
||||
|
||||
def update_deployment_status(stack_name, status, working_dir):
|
||||
"""Update the deployment status."""
|
||||
|
||||
if not os.path.exists(working_dir):
|
||||
makedirs(working_dir)
|
||||
contents = yaml.safe_dump(
|
||||
{'deployment_status': status},
|
||||
default_flow_style=False)
|
||||
|
||||
safe_write(get_status_yaml(stack_name, working_dir),
|
||||
contents)
|
||||
|
||||
|
||||
def check_file_for_enabled_service(env_file):
|
||||
"""Checks environment file for the said service.
|
||||
|
||||
|
||||
@@ -1058,7 +1058,7 @@ class DeployOvercloud(command.Command):
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
self.log.debug("take_action(%s)" % parsed_args)
|
||||
deploy_status = 'success'
|
||||
deploy_status = 'DEPLOY_SUCCESS'
|
||||
deploy_message = 'without error'
|
||||
|
||||
self._setup_clients(parsed_args)
|
||||
@@ -1105,6 +1105,7 @@ class DeployOvercloud(command.Command):
|
||||
# Get a new copy of the stack after stack update/create. If it was
|
||||
# a create then the previous stack object would be None.
|
||||
stack = utils.get_stack(self.orchestration_client, parsed_args.stack)
|
||||
working_dir = utils.get_default_working_dir(parsed_args.stack)
|
||||
|
||||
if parsed_args.update_plan_only:
|
||||
# If we are only updating the plan, then we either wont have a
|
||||
@@ -1129,8 +1130,11 @@ class DeployOvercloud(command.Command):
|
||||
if parsed_args.config_download:
|
||||
print("Deploying overcloud configuration")
|
||||
deployment.set_deployment_status(
|
||||
self.clients, 'deploying',
|
||||
plan=stack.stack_name)
|
||||
clients=self.clients,
|
||||
status='DEPLOYING',
|
||||
working_dir=working_dir,
|
||||
plan=stack.stack_name,
|
||||
)
|
||||
|
||||
if not parsed_args.config_download_only:
|
||||
deployment.get_hosts_and_enable_ssh_admin(
|
||||
@@ -1172,13 +1176,21 @@ class DeployOvercloud(command.Command):
|
||||
),
|
||||
forks=parsed_args.ansible_forks
|
||||
)
|
||||
deployment.set_deployment_status(
|
||||
clients=self.clients,
|
||||
status=deploy_status,
|
||||
working_dir=working_dir,
|
||||
plan=stack.stack_name)
|
||||
except Exception as deploy_e:
|
||||
deploy_status = 'failed'
|
||||
deploy_status = 'DEPLOY_FAILED'
|
||||
deploy_message = 'with error'
|
||||
deploy_trace = deploy_e
|
||||
deployment.set_deployment_status(
|
||||
self.clients, deploy_status,
|
||||
plan=stack.stack_name)
|
||||
clients=self.clients,
|
||||
status=deploy_status,
|
||||
working_dir=working_dir,
|
||||
plan=stack.stack_name,
|
||||
)
|
||||
finally:
|
||||
# Copy clouds.yaml to the cloud user directory
|
||||
user = getpwuid(os.stat(constants.CLOUD_HOME_DIR).st_uid).pw_name
|
||||
@@ -1195,8 +1207,7 @@ class DeployOvercloud(command.Command):
|
||||
print("Overcloud Horizon Dashboard URL: {0}".format(horizon_url))
|
||||
print("Overcloud rc file: {0}".format(rcpath))
|
||||
print("Overcloud Deployed {0}".format(deploy_message))
|
||||
|
||||
if deploy_status == 'failed':
|
||||
if deploy_status == 'DEPLOY_FAILED':
|
||||
raise(deploy_trace)
|
||||
|
||||
|
||||
|
||||
@@ -304,7 +304,9 @@ class UpgradeConverge(UpgradePrepare):
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
super(UpgradeConverge, self).take_action(parsed_args)
|
||||
working_dir = oooutils.get_default_working_dir(parsed_args.stack)
|
||||
deployment.set_deployment_status(
|
||||
self.clients,
|
||||
status='success',
|
||||
status='DEPLOY_SUCCESS',
|
||||
working_dir=working_dir,
|
||||
plan=parsed_args.stack)
|
||||
|
||||
@@ -107,9 +107,12 @@ def deploy_and_wait(log, clients, stack, plan_name, verbose_level,
|
||||
verbose_events = verbose_level >= 1
|
||||
create_result = utils.wait_for_stack_ready(
|
||||
orchestration_client, plan_name, marker, action, verbose_events)
|
||||
working_dir = utils.get_default_working_dir(plan_name)
|
||||
if not create_result:
|
||||
shell.OpenStackShell().run(["stack", "failures", "list", plan_name])
|
||||
set_deployment_status(clients, 'failed', plan=plan_name)
|
||||
set_deployment_status(clients, 'DEPLOY_FAILED',
|
||||
working_dir=working_dir,
|
||||
plan=plan_name)
|
||||
if stack is None:
|
||||
raise exceptions.DeploymentError("Heat Stack create failed.")
|
||||
else:
|
||||
@@ -473,15 +476,17 @@ def get_deployment_status(clients, **workflow_input):
|
||||
payload.get('message', '')))
|
||||
|
||||
|
||||
def set_deployment_status(clients, status='success', **workflow_input):
|
||||
def set_deployment_status(clients, status='success',
|
||||
working_dir='/home/stack/overcloud-deploy/overcloud',
|
||||
**workflow_input):
|
||||
workflow_client = clients.workflow_engine
|
||||
tripleoclients = clients.tripleoclient
|
||||
|
||||
if status == 'success':
|
||||
if status == 'DEPLOY_SUCCESS':
|
||||
workflow = 'tripleo.deployment.v1.set_deployment_status_success'
|
||||
elif status == 'failed':
|
||||
elif status == 'DEPLOY_FAILED':
|
||||
workflow = 'tripleo.deployment.v1.set_deployment_status_failed'
|
||||
elif status == 'deploying':
|
||||
elif status == 'DEPLOYING':
|
||||
workflow = 'tripleo.deployment.v1.set_deployment_status_deploying'
|
||||
else:
|
||||
raise Exception("Can't set unknown deployment status: %s" % status)
|
||||
@@ -498,6 +503,11 @@ def set_deployment_status(clients, status='success', **workflow_input):
|
||||
# Just continue until workflow is done
|
||||
continue
|
||||
|
||||
utils.update_deployment_status(
|
||||
stack_name=workflow_input['plan'],
|
||||
status=status,
|
||||
working_dir=working_dir)
|
||||
|
||||
if payload['status'] != 'SUCCESS':
|
||||
raise exceptions.WorkflowServiceError(
|
||||
'Exception setting deployment status: {}'.format(
|
||||
|
||||
Reference in New Issue
Block a user