Merge "Fix update run for Ephemeral Heat"

This commit is contained in:
Zuul
2021-09-20 18:32:45 +00:00
committed by Gerrit Code Review
4 changed files with 105 additions and 53 deletions

View File

@@ -0,0 +1,10 @@
---
prelude: >
During a minor update of the overcloud. It was previously necessary to
execute 3 steps.
- Update Prepare
- Update Run
- Update Converge
Starting in W, it is no longer necessary to perform a Stack update
during the converge. This change removes the stack update from the
converge step. Now, we will just run the deploy_steps_playbook instead.

View File

@@ -101,7 +101,6 @@ EXTERNAL_UPGRADE_PLAYBOOKS = ['external_upgrade_steps_playbook.yaml']
# upgrade environment files expected by the client in the --templates # upgrade environment files expected by the client in the --templates
# tripleo-heat-templates default above $TRIPLEO_HEAT_TEMPLATES # tripleo-heat-templates default above $TRIPLEO_HEAT_TEMPLATES
UPDATE_PREPARE_ENV = "environments/lifecycle/update-prepare.yaml" UPDATE_PREPARE_ENV = "environments/lifecycle/update-prepare.yaml"
UPDATE_CONVERGE_ENV = "environments/lifecycle/update-converge.yaml"
UPGRADE_PREPARE_ENV = "environments/lifecycle/upgrade-prepare.yaml" UPGRADE_PREPARE_ENV = "environments/lifecycle/upgrade-prepare.yaml"
UPGRADE_CONVERGE_ENV = "environments/lifecycle/upgrade-converge.yaml" UPGRADE_CONVERGE_ENV = "environments/lifecycle/upgrade-converge.yaml"
UPGRADE_CONVERGE_FORBIDDEN_PARAMS = ["ceph3_namespace", UPGRADE_CONVERGE_FORBIDDEN_PARAMS = ["ceph3_namespace",

View File

@@ -139,35 +139,57 @@ class TestOvercloudUpdateRun(fakes.TestOvercloudUpdateRun):
class TestOvercloudUpdateConverge(fakes.TestOvercloudUpdateConverge): class TestOvercloudUpdateConverge(fakes.TestOvercloudUpdateConverge):
def setUp(self): def setUp(self):
super(TestOvercloudUpdateConverge, self).setUp() super(TestOvercloudUpdateConverge, self).setUp()
# Get the command object to test # Get the command object to test
app_args = mock.Mock() app_args = mock.Mock()
app_args.verbose_level = 1 app_args.verbose_level = 1
self.cmd = overcloud_update.UpdateConverge(self.app, app_args) self.cmd = overcloud_update.UpdateConverge(self.app, app_args)
@mock.patch('tripleoclient.utils.get_key')
@mock.patch('tripleoclient.utils.get_default_working_dir')
@mock.patch('tripleoclient.utils.ensure_run_as_normal_user') @mock.patch('tripleoclient.utils.ensure_run_as_normal_user')
@mock.patch('tripleoclient.utils.prompt_user_for_confirmation', @mock.patch('tripleoclient.utils.prompt_user_for_confirmation',
return_value=True) return_value=True)
@mock.patch( @mock.patch(
'tripleoclient.v1.overcloud_deploy.DeployOvercloud.take_action') 'tripleoclient.utils.run_ansible_playbook')
def test_update_converge(self, deploy_action, mock_confirm, def test_update_converge(self, deploy_action, mock_confirm,
mock_usercheck): mock_usercheck, mock_dir, mock_key):
argslist = ['--templates', '--stack', 'cloud'] argslist = ['--stack', 'cloud']
verifylist = [ verifylist = [
('stack', 'cloud') ('stack', 'cloud')
] ]
parsed_args = self.check_parser(self.cmd, argslist, verifylist) mock_dir.return_value = "/home/stack/overcloud-deploy"
ansible_dir = "{}/config-download/cloud".format(
mock_dir.return_value
)
inventory = "{}/tripleo-ansible-inventory.yaml".format(
ansible_dir
)
ansible_cfg = "{}/ansible.cfg".format(
ansible_dir
)
mock_key.return_value = '/home/stack/.ssh/id_rsa_tripleo'
parsed_args = self.check_parser(self.cmd, argslist, verifylist)
with mock.patch('os.path.exists') as mock_exists, \ with mock.patch('os.path.exists') as mock_exists, \
mock.patch('os.path.isfile') as mock_isfile: mock.patch('os.path.isfile') as mock_isfile:
mock_exists.return_value = True mock_exists.return_value = True
mock_isfile.return_value = True mock_isfile.return_value = True
self.cmd.take_action(parsed_args) self.cmd.take_action(parsed_args)
mock_usercheck.assert_called_once() mock_usercheck.assert_called_once()
assert('/usr/share/openstack-tripleo-heat-templates/' deploy_action.assert_called_once_with(
'environments/lifecycle/update-converge.yaml' playbook='deploy_steps_playbook.yaml',
in parsed_args.environment_files) inventory=inventory,
deploy_action.assert_called_once_with(parsed_args) workdir=ansible_dir,
playbook_dir=ansible_dir,
ansible_cfg=ansible_cfg,
ssh_user='tripleo-admin',
reproduce_command=True,
forks=parsed_args.ansible_forks,
extra_env_variables={
"ANSIBLE_BECOME": True,
"ANSIBLE_PRIVATE_KEY_FILE":
"/home/stack/.ssh/id_rsa_tripleo"
}
)

View File

@@ -12,6 +12,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
# #
import os
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
@@ -24,18 +26,17 @@ from tripleoclient import command
from tripleoclient import constants from tripleoclient import constants
from tripleoclient import utils as oooutils from tripleoclient import utils as oooutils
from tripleoclient.v1.overcloud_deploy import DeployOvercloud from tripleoclient.v1.overcloud_deploy import DeployOvercloud
from tripleoclient.workflows import deployment
CONF = cfg.CONF CONF = cfg.CONF
class UpdatePrepare(DeployOvercloud): class UpdatePrepare(DeployOvercloud):
"""Run heat stack update for overcloud nodes to refresh heat stack outputs. """Use Heat to update and render the new Ansible playbooks based
on the updated templates.
The heat stack outputs are what we use later on to generate ansible These playbooks will be rendered and used during the update run step
playbooks which deliver the minor update workflow. This is used as the to perform the minor update of the overcloud nodes.
first step for a minor update of your overcloud.
""" """
log = logging.getLogger(__name__ + ".MinorUpdatePrepare") log = logging.getLogger(__name__ + ".MinorUpdatePrepare")
@@ -188,44 +189,46 @@ class UpdateRun(command.Command):
else: else:
playbook = parsed_args.playbook playbook = parsed_args.playbook
_, ansible_dir = self.get_ansible_key_and_dir( ansible_dir = os.path.join(oooutils.get_default_working_dir(
no_workflow=True,
stack=parsed_args.stack,
orchestration=self.app.client_manager.orchestration
)
deployment.config_download(
log=self.log,
clients=self.app.client_manager,
stack=oooutils.get_stack(
self.app.client_manager.orchestration,
parsed_args.stack parsed_args.stack
), ),
output_dir=ansible_dir, 'config-download',
verbosity=oooutils.playbook_verbosity(self=self), parsed_args.stack)
ansible_playbook_name=playbook,
inventory_path=oooutils.get_tripleo_ansible_inventory( if not parsed_args.static_inventory:
parsed_args.static_inventory, inventory = os.path.join(ansible_dir,
parsed_args.ssh_user, 'tripleo-ansible-inventory.yaml')
parsed_args.stack, else:
return_inventory_file_path=True inventory = parsed_args.static_inventory
),
limit_hosts=oooutils.playbook_limit_parse( ansible_cfg = os.path.join(ansible_dir, 'ansible.cfg')
limit_nodes=parsed_args.limit key_file = oooutils.get_key(parsed_args.stack)
),
oooutils.run_ansible_playbook(
playbook=playbook,
inventory=inventory,
workdir=ansible_dir,
playbook_dir=ansible_dir,
skip_tags=parsed_args.skip_tags, skip_tags=parsed_args.skip_tags,
tags=parsed_args.tags, tags=parsed_args.tags,
forks=parsed_args.ansible_forks ansible_cfg=ansible_cfg,
ssh_user='tripleo-admin',
limit_hosts=parsed_args.limit,
reproduce_command=True,
forks=parsed_args.ansible_forks,
extra_env_variables={
"ANSIBLE_BECOME": True,
"ANSIBLE_PRIVATE_KEY_FILE": key_file
}
) )
self.log.info("Completed Overcloud Minor Update Run.") self.log.info("Completed Minor Update Run.")
class UpdateConverge(DeployOvercloud): class UpdateConverge(DeployOvercloud):
"""Converge the update on Overcloud nodes. """Converge the update on Overcloud nodes.
This restores the plan and stack so that normal deployment This restores the plan and stack so that normal deployment
workflow is back in place. workflow is back in place.
""" """
log = logging.getLogger(__name__ + ".UpdateConverge") log = logging.getLogger(__name__ + ".UpdateConverge")
def get_parser(self, prog_name): def get_parser(self, prog_name):
@@ -236,6 +239,7 @@ class UpdateConverge(DeployOvercloud):
"required before any update operation. " "required before any update operation. "
"Use this with caution! "), "Use this with caution! "),
) )
return parser return parser
def take_action(self, parsed_args): def take_action(self, parsed_args):
@@ -249,13 +253,30 @@ class UpdateConverge(DeployOvercloud):
constants.UPDATE_PROMPT, self.log)): constants.UPDATE_PROMPT, self.log)):
raise OvercloudUpdateNotConfirmed(constants.UPDATE_NO) raise OvercloudUpdateNotConfirmed(constants.UPDATE_NO)
# Add the update-converge.yaml environment to unset noops ansible_dir = os.path.join(oooutils.get_default_working_dir(
templates_dir = (parsed_args.templates or parsed_args.stack
constants.TRIPLEO_HEAT_TEMPLATES) ),
parsed_args.environment_files = oooutils.prepend_environment( 'config-download',
parsed_args.environment_files, templates_dir, parsed_args.stack)
constants.UPDATE_CONVERGE_ENV)
super(UpdateConverge, self).take_action(parsed_args) inventory = os.path.join(ansible_dir,
self.log.info("Update converge on stack {0} complete.".format( 'tripleo-ansible-inventory.yaml')
parsed_args.stack))
ansible_cfg = os.path.join(ansible_dir, 'ansible.cfg')
key_file = oooutils.get_key(parsed_args.stack)
oooutils.run_ansible_playbook(
playbook='deploy_steps_playbook.yaml',
inventory=inventory,
workdir=ansible_dir,
playbook_dir=ansible_dir,
ansible_cfg=ansible_cfg,
ssh_user='tripleo-admin',
reproduce_command=True,
forks=parsed_args.ansible_forks,
extra_env_variables={
"ANSIBLE_BECOME": True,
"ANSIBLE_PRIVATE_KEY_FILE": key_file
}
)
self.log.info("Completed Minor Update Converge.")