standalone/undercloud: run post_upgrade_tasks when upgrading

This changes the upgrade workflow for the standalone and undercloud
where we now run the post_upgrade_tasks after the deployment.
So the order is upgrade_tasks, deployment steps (docker/puppet),
then post_upgrade_tasks which is the same order as the overcloud.
It will allow us to execute some specific post upgrade tasks on standalone
and undercloud, like removing Docker containers when upgrading to Podman.

Change-Id: I311bfa17a3bbe52850092d501d563d53f7095a24
This commit is contained in:
Emilien Macchi 2018-10-30 16:47:48 -04:00
parent dd6eafe6fe
commit ae1f1e0008
3 changed files with 39 additions and 1 deletions

View File

@ -0,0 +1,9 @@
---
features:
- |
This changes the upgrade workflow for the standalone and undercloud
where we now run the post_upgrade_tasks after the deployment.
So the order is upgrade_tasks, deployment steps (docker/puppet),
then post_upgrade_tasks which is the same order as the overcloud.
It will allow us to execute some specific post upgrade tasks on standalone
and undercloud, like removing Docker containers when upgrading to Podman.

View File

@ -44,6 +44,20 @@ class TestUpgrade(utils.TestCommand):
'upgrade_steps_playbook.yaml',
'--skip-tags', 'validation'])
@mock.patch('tripleoclient.utils.'
'run_command_and_log', autospec=True)
@mock.patch('os.chdir')
@mock.patch('os.execvp')
def test_launch_ansible_post_upgrade(self, mock_execvp, mock_chdir,
mock_run):
self.cmd._launch_ansible_post_upgrade('/tmp')
mock_chdir.assert_called_once()
mock_run.assert_called_once_with(self.cmd.log, [
'ansible-playbook', '-i', '/tmp/inventory.yaml',
'post_upgrade_steps_playbook.yaml',
'--skip-tags', 'validation'])
@mock.patch('tripleoclient.v1.tripleo_deploy.Deploy.take_action',
autospec=True)
def test_take_action(self, mock_deploy):

View File

@ -803,6 +803,16 @@ class Deploy(command.Command):
self.log.debug('Running Ansible Upgrade tasks: %s' % (' '.join(cmd)))
return utils.run_command_and_log(self.log, cmd)
def _launch_ansible_post_upgrade(self, ansible_dir):
self.log.warning('** Running ansible post-upgrade tasks **')
os.chdir(ansible_dir)
playbook_inventory = os.path.join(ansible_dir, 'inventory.yaml')
cmd = ['ansible-playbook', '-i', playbook_inventory,
'post_upgrade_steps_playbook.yaml', '--skip-tags', 'validation']
self.log.debug('Running Ansible Post Upgrade '
'tasks: %s' % (' '.join(cmd)))
return utils.run_command_and_log(self.log, cmd)
def get_parser(self, prog_name):
parser = argparse.ArgumentParser(
description=self.get_description(),
@ -1146,12 +1156,17 @@ class Deploy(command.Command):
if not parsed_args.keep_running:
self._kill_heat(parsed_args)
if not parsed_args.output_only:
# Run Upgrade tasks before the deployment
if parsed_args.upgrade:
# Run Upgrade tasks before the deployment
rc = self._launch_ansible_upgrade(self.ansible_dir)
if rc != 0:
raise exceptions.DeploymentError('Upgrade failed')
rc = self._launch_ansible_deploy(self.ansible_dir)
if parsed_args.upgrade:
# Run Post Upgrade tasks after the deployment
rc = self._launch_ansible_post_upgrade(self.ansible_dir)
if rc != 0:
raise exceptions.DeploymentError('Post Upgrade failed')
except Exception as e:
self.log.error("Exception: %s" % six.text_type(e))
self.log.error(traceback.print_exc())