Remove ffwd-upgrade commands from tripleoclient.

Now that the FFU process relies on the openstack overcloud upgrade
commands there is no need to keep the old ffwd-upgrade command
available.

This patch removes the three ffwd-upgrade (run, prepare and converge)
as well as their tests, utils functions and constants.

Change-Id: If0c0ed9a44a51cf367fd060c77e10055f367694c
This commit is contained in:
Jose Luis Franco Arza 2020-07-02 14:43:36 +02:00
parent c305772c97
commit 8e7331098e
8 changed files with 8 additions and 508 deletions

View File

@ -0,0 +1,7 @@
---
deprecations:
- |
The ffwd-upgrade command isn't needed anymore since Queens. The ffwd upgrade
now relies on the overcloud upgrade commands, therefore there is no need to
keep the old ffwd-upgrade commands around as they could just cause confusion
to the user.

View File

@ -100,9 +100,6 @@ openstack.tripleoclient.v2 =
overcloud_upgrade_converge = tripleoclient.v1.overcloud_upgrade:UpgradeConvergeOvercloud
overcloud_external-update_run = tripleoclient.v1.overcloud_external_update:ExternalUpdateRun
overcloud_external-upgrade_run = tripleoclient.v1.overcloud_external_upgrade:ExternalUpgradeRun
overcloud_ffwd-upgrade_prepare = tripleoclient.v1.overcloud_ffwd_upgrade:FFWDUpgradePrepare
overcloud_ffwd-upgrade_run = tripleoclient.v1.overcloud_ffwd_upgrade:FFWDUpgradeRun
overcloud_ffwd-upgrade_converge = tripleoclient.v1.overcloud_ffwd_upgrade:FFWDUpgradeConverge
overcloud_generate_fencing = tripleoclient.v1.overcloud_parameters:GenerateFencingParameters
tripleo_container_image_build = tripleoclient.v2.tripleo_container_image:Build
tripleo_container_image_hotfix = tripleoclient.v2.tripleo_container_image:HotFix

View File

@ -63,8 +63,6 @@ STACK_TIMEOUT = 240
IRONIC_HTTP_BOOT_BIND_MOUNT = '/var/lib/ironic/httpboot'
IRONIC_LOCAL_IMAGE_PATH = '/var/lib/ironic/images'
# The default ffwd upgrade ansible playbooks generated from heat stack output
FFWD_UPGRADE_PLAYBOOK = "fast_forward_upgrade_playbook.yaml"
# The default minor update ansible playbooks generated from heat stack output
MINOR_UPDATE_PLAYBOOKS = ['update_steps_playbook.yaml']
# The default major upgrade ansible playbooks generated from heat stack output
@ -88,8 +86,6 @@ UPGRADE_CONVERGE_FORBIDDEN_PARAMS = ["ceph3_namespace",
"namespace_stein",
"tag_stein",
]
FFWD_UPGRADE_PREPARE_ENV = "environments/lifecycle/ffwd-upgrade-prepare.yaml"
FFWD_UPGRADE_CONVERGE_ENV = "environments/lifecycle/ffwd-upgrade-converge.yaml"
ENABLE_SSH_ADMIN_TIMEOUT = 600
ENABLE_SSH_ADMIN_STATUS_INTERVAL = 5
@ -192,7 +188,7 @@ EXPORT_PASSWORD_EXCLUDE_PATTERNS = [
]
# Package that need to be to the latest before undercloud
# update/update/ffwd.
# update/update
UNDERCLOUD_EXTRA_PACKAGES = [
"openstack-tripleo-common",
"openstack-tripleo-heat-templates",

View File

@ -1,34 +0,0 @@
# Copyright 2018 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
from tripleoclient.tests import fakes
class TestFFWDUpgradePrepare(fakes.FakePlaybookExecution):
def setUp(self):
super(TestFFWDUpgradePrepare, self).setUp()
class TestFFWDUpgradeRun(fakes.FakePlaybookExecution):
def setUp(self):
super(TestFFWDUpgradeRun, self).setUp()
class TestFFWDUpgradeConverge(fakes.FakePlaybookExecution):
def setUp(self):
super(TestFFWDUpgradeConverge, self).setUp()

View File

@ -1,231 +0,0 @@
# Copyright 2018 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
import mock
from osc_lib.tests.utils import ParserException
from tripleoclient import constants
from tripleoclient import exceptions
from tripleoclient.tests.v1.overcloud_ffwd_upgrade import fakes
from tripleoclient.v1 import overcloud_ffwd_upgrade
class TestFFWDUpgradePrepare(fakes.TestFFWDUpgradePrepare):
def setUp(self):
super(TestFFWDUpgradePrepare, self).setUp()
# Get the command object to test
app_args = mock.Mock()
app_args.verbose_level = 1
self.cmd = overcloud_ffwd_upgrade.FFWDUpgradePrepare(self.app,
app_args)
uuid4_patcher = mock.patch('uuid.uuid4', return_value="UUID4")
self.mock_uuid4 = uuid4_patcher.start()
self.addCleanup(self.mock_uuid4.stop)
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
'take_action')
@mock.patch('tripleoclient.workflows.deployment.'
'get_hosts_and_enable_ssh_admin', autospec=True)
@mock.patch('tripleoclient.workflows.deployment.create_overcloudrc',
autospec=True)
@mock.patch('tripleoclient.utils.prepend_environment', autospec=True)
@mock.patch('tripleoclient.utils.get_stack',
autospec=True)
@mock.patch(
'tripleoclient.v1.overcloud_ffwd_upgrade.FFWDUpgradePrepare.log',
autospec=True)
@mock.patch('tripleoclient.workflows.package_update.update',
autospec=True)
@mock.patch('os.path.abspath')
@mock.patch('yaml.safe_load')
@mock.patch('shutil.copytree', autospec=True)
@mock.patch('six.moves.builtins.open')
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
'_deploy_tripleo_heat_templates', autospec=True)
def test_ffwd_upgrade(self,
mock_deploy,
mock_open,
mock_copy,
mock_yaml,
mock_abspath,
mock_ffwd_upgrade,
mock_logger,
mock_get_stack,
mock_prepend_env,
mock_overcloudrc,
mock_enable_ssh_admin,
mock_overcloud_deploy):
mock_stack = mock.Mock()
mock_stack.stack_name = 'mystack'
mock_get_stack.return_value = mock_stack
mock_yaml.return_value = {'fake_container': 'fake_value'}
argslist = ['--stack', 'mystack', '--templates',
'--yes']
verifylist = [
('stack', 'mystack'),
('templates', constants.TRIPLEO_HEAT_TEMPLATES),
('yes', True),
]
parsed_args = self.check_parser(self.cmd, argslist, verifylist)
self.cmd.take_action(parsed_args)
mock_ffwd_upgrade.assert_called_once_with(
self.app.client_manager,
container='mystack',
)
mock_overcloudrc.assert_called_once_with(container="mystack")
mock_enable_ssh_admin.assert_called_once_with(
mock_stack,
parsed_args.overcloud_ssh_network,
parsed_args.overcloud_ssh_user,
mock.ANY,
parsed_args.overcloud_ssh_port_timeout,
mock.ANY
)
mock_overcloud_deploy.assert_called_once_with(parsed_args)
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
'take_action')
@mock.patch('tripleoclient.utils.prepend_environment', autospec=True)
@mock.patch('tripleoclient.workflows.package_update.update',
autospec=True)
@mock.patch('six.moves.builtins.open')
@mock.patch('os.path.abspath')
@mock.patch('yaml.safe_load')
@mock.patch('shutil.copytree', autospec=True)
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
'_deploy_tripleo_heat_templates', autospec=True)
def test_ffwd_upgrade_failed(
self, mock_deploy, mock_copy, mock_yaml, mock_abspath, mock_open,
mock_ffwd_upgrade, mock_prepend_env, mock_overcloud_deploy):
mock_ffwd_upgrade.side_effect = exceptions.DeploymentError()
mock_yaml.return_value = {'fake_container': 'fake_value'}
argslist = ['--stack', 'overcloud', '--templates',
'--yes', ]
verifylist = [
('stack', 'overcloud'),
('templates', constants.TRIPLEO_HEAT_TEMPLATES),
('yes', True),
]
parsed_args = self.check_parser(self.cmd, argslist, verifylist)
self.assertRaises(exceptions.DeploymentError,
self.cmd.take_action, parsed_args)
mock_overcloud_deploy.assert_called_once_with(parsed_args)
class TestFFWDUpgradeRun(fakes.TestFFWDUpgradeRun):
def setUp(self):
super(TestFFWDUpgradeRun, self).setUp()
# Get the command object to test
app_args = mock.Mock()
app_args.verbose_level = 1
self.cmd = overcloud_ffwd_upgrade.FFWDUpgradeRun(self.app, app_args)
uuid4_patcher = mock.patch('uuid.uuid4', return_value="UUID4")
self.mock_uuid4 = uuid4_patcher.start()
self.addCleanup(self.mock_uuid4.stop)
@mock.patch('tripleoclient.utils.run_ansible_playbook',
autospec=True)
@mock.patch('os.path.expanduser')
@mock.patch('oslo_concurrency.processutils.execute')
@mock.patch('six.moves.builtins.open')
def test_ffwd_upgrade_playbook(
self, mock_open, mock_execute, mock_expanduser, upgrade_ansible):
mock_expanduser.return_value = '/home/fake/'
argslist = ['--ssh-user', 'heat-admin', '--yes']
verifylist = [('ssh_user', 'heat-admin'), ('yes', True), ]
self.check_parser(self.cmd, argslist, verifylist)
@mock.patch('tripleoclient.utils.run_ansible_playbook',
autospec=True)
@mock.patch('os.path.expanduser')
@mock.patch('oslo_concurrency.processutils.execute')
@mock.patch('six.moves.builtins.open')
def test_ffwd_upgrade_playbook_non_default_user(
self, mock_open, mock_execute, mock_expanduser, upgrade_ansible):
mock_expanduser.return_value = '/home/fake/'
argslist = ['--ssh-user', 'my-user', '--yes']
verifylist = [('ssh_user', 'my-user'), ('yes', True), ]
self.check_parser(self.cmd, argslist, verifylist)
@mock.patch('tripleoclient.utils.run_ansible_playbook',
autospec=True)
@mock.patch('os.path.expanduser')
@mock.patch('oslo_concurrency.processutils.execute')
@mock.patch('six.moves.builtins.open')
def test_upgrade_no_nodes_or_roles(self, mock_open, mock_execute,
mock_expanduser, upgrade_ansible):
mock_expanduser.return_value = '/home/fake/'
argslist = ["--limit", "controller-1", "--roles", "foo", "--yes"]
verifylist = []
self.assertRaises(ParserException, lambda: self.check_parser(
self.cmd, argslist, verifylist))
@mock.patch('tripleoclient.utils.run_ansible_playbook',
autospec=True)
@mock.patch('os.path.expanduser')
@mock.patch('oslo_concurrency.processutils.execute')
@mock.patch('six.moves.builtins.open')
def test_upgrade_limit(self, mock_open, mock_execute,
mock_expanduser, upgrade_ansible):
mock_expanduser.return_value = '/home/fake/'
argslist = ['--limit', 'controller1,controller2,controll3']
verifylist = [('limit', 'controller1,controller2,controll3')]
self.assertRaises(ParserException, lambda: self.check_parser(
self.cmd, argslist, verifylist))
class TestFFWDUpgradeConverge(fakes.TestFFWDUpgradeConverge):
def setUp(self):
super(TestFFWDUpgradeConverge, self).setUp()
# Get the command object to test
app_args = mock.Mock()
app_args.verbose_level = 1
self.cmd = overcloud_ffwd_upgrade.FFWDUpgradeConverge(self.app,
app_args)
@mock.patch(
'tripleoclient.v1.overcloud_deploy.DeployOvercloud.take_action')
def test_ffwd_upgrade_converge(self, deploy_action):
argslist = ['--stack', 'le_overcloud', '--templates', '--yes']
verifylist = [
('stack', 'le_overcloud'),
('templates', constants.TRIPLEO_HEAT_TEMPLATES),
('yes', True)
]
parsed_args = self.check_parser(self.cmd, argslist, verifylist)
with mock.patch('os.path.exists') as mock_exists, \
mock.patch('os.path.isfile') as mock_isfile:
mock_exists.return_value = True
mock_isfile.return_value = True
self.cmd.take_action(parsed_args)
assert('/usr/share/openstack-tripleo-heat-templates/'
'environments/lifecycle/ffwd-upgrade-converge.yaml'
in parsed_args.environment_files)
deploy_action.assert_called_once_with(parsed_args)

View File

@ -1808,32 +1808,6 @@ def run_command_and_log(log, cmd, cwd=None, env=None, retcode_only=True):
return proc
def ffwd_upgrade_operator_confirm(parsed_args_yes, log):
print("\nWarning! The TripleO Fast Forward Upgrade "
"workflow is a critical operation against the deployed "
"environment.\nOnce and if you decide to use ffwd-upgrade "
"in production, ensure you are adequately prepared "
"with valid backup of your current deployment state.\n")
if parsed_args_yes:
log.debug(_("Fast forward upgrade --yes continuing"))
print(_("Continuing fast forward upgrade"))
return
else:
# Fix Python 2.x.
try:
input = raw_input
except NameError:
pass
response = input("Proceed with the fast forward upgrade? "
"Type 'yes' to continue and anything else to "
"cancel.\nConsider using the --yes parameter if "
"you wish to skip this warning in future. ")
if response != 'yes':
log.debug(_("Fast forward upgrade cancelled on user request"))
print(_("Cancelling fast forward upgrade"))
sys.exit(1)
def build_prepare_env(environment_files, environment_directories):
'''Build the environment for container image prepare

View File

@ -1,209 +0,0 @@
# Copyright 2018 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
from oslo_config import cfg
from oslo_log import log as logging
from osc_lib.i18n import _
from osc_lib import utils
from tripleoclient import command
from tripleoclient import constants
from tripleoclient import utils as oooutils
from tripleoclient.v1.overcloud_deploy import DeployOvercloud
from tripleoclient.workflows import deployment
from tripleoclient.workflows import package_update
CONF = cfg.CONF
logging.register_options(CONF)
logging.setup(CONF, '')
class FFWDUpgradePrepare(DeployOvercloud):
"""Run heat stack update for overcloud nodes to refresh heat stack outputs.
The heat stack outputs are what we use later on to generate ansible
playbooks which deliver the ffwd upgrade workflow. This is used as the
first step for a fast forward upgrade of your overcloud.
"""
log = logging.getLogger(__name__ + ".FFWDUpgradePrepare")
def get_parser(self, prog_name):
parser = super(FFWDUpgradePrepare, self).get_parser(prog_name)
parser.add_argument('--yes',
action='store_true',
help=_("Use --yes to skip the confirmation "
"required before any ffwd-upgrade "
"operation. Use this with caution! "),
)
return parser
def take_action(self, parsed_args):
self.log.debug("take_action(%s)" % parsed_args)
oooutils.ffwd_upgrade_operator_confirm(parsed_args.yes, self.log)
clients = self.app.client_manager
stack = oooutils.get_stack(clients.orchestration,
parsed_args.stack)
stack_name = stack.stack_name
# In case of update and upgrade we need to force the
# update_plan_only. The heat stack update is done by the
# packag_update mistral action
parsed_args.update_plan_only = True
# Add the prepare environment into the args to unset noop etc
templates_dir = (parsed_args.templates or
constants.TRIPLEO_HEAT_TEMPLATES)
if not parsed_args.environment_files:
parsed_args.environment_files = []
parsed_args.environment_files = oooutils.prepend_environment(
parsed_args.environment_files, templates_dir,
constants.FFWD_UPGRADE_PREPARE_ENV)
super(FFWDUpgradePrepare, self).take_action(parsed_args)
package_update.update(clients, container=stack_name)
deployment.create_overcloudrc(container=stack_name)
# refresh stack info and enable ssh admin for Ansible-via-Mistral
stack = oooutils.get_stack(clients.orchestration, parsed_args.stack)
deployment.get_hosts_and_enable_ssh_admin(
stack,
parsed_args.overcloud_ssh_network,
parsed_args.overcloud_ssh_user,
self.get_key_pair(parsed_args),
parsed_args.overcloud_ssh_port_timeout,
verbosity=oooutils.playbook_verbosity(self=self)
)
self.log.info("FFWD Upgrade Prepare on stack {0} complete.".format(
parsed_args.stack))
class FFWDUpgradeRun(command.Command):
"""Run fast forward upgrade ansible playbooks on Overcloud nodes
This will run the fast_forward_upgrade_playbook.yaml ansible playbook.
This playbook was generated when you ran the 'ffwd-upgrade prepare'
command. Running 'ffwd-upgrade run ' is the second step in the ffwd
upgrade workflow.
"""
log = logging.getLogger(__name__ + ".FFWDUpgradeRun")
def get_parser(self, prog_name):
parser = super(FFWDUpgradeRun, self).get_parser(prog_name)
parser.add_argument('--yes',
action='store_true',
help=_("Use --yes to skip the confirmation "
"required before any ffwd-upgrade "
"operation. Use this with caution! "),
)
parser.add_argument('--static-inventory',
dest='static_inventory',
action="store",
default=None,
help=_('Path to an existing ansible inventory to '
'use. If not specified, one will be '
'generated in '
'~/tripleo-ansible-inventory.yaml')
)
parser.add_argument("--ssh-user",
dest="ssh_user",
action="store",
default="tripleo-admin",
help=_("DEPRECATED: Only tripleo-admin should be "
"used as ssh user.")
)
parser.add_argument('--stack', dest='stack',
help=_('Name or ID of heat stack '
'(default=Env: OVERCLOUD_STACK_NAME)'),
default=utils.env('OVERCLOUD_STACK_NAME',
default='overcloud')
)
parser.add_argument('--no-workflow', dest='no_workflow',
action='store_true',
default=True,
help=_('This option no longer has any effect.')
)
return parser
def take_action(self, parsed_args):
self.log.debug("take_action(%s)" % parsed_args)
_, ansible_dir = self.get_ansible_key_and_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
),
output_dir=ansible_dir,
verbosity=oooutils.playbook_verbosity(self=self),
ansible_playbook_name=constants.FFWD_UPGRADE_PLAYBOOK,
inventory_path=oooutils.get_tripleo_ansible_inventory(
parsed_args.static_inventory,
parsed_args.ssh_user,
parsed_args.stack,
return_inventory_file_path=True
)
)
self.log.info("Completed Overcloud FFWD Upgrade Run.")
class FFWDUpgradeConverge(DeployOvercloud):
"""Converge the fast-forward upgrade on Overcloud Nodes
This is the last step for completion of a fast forward upgrade.
The main task is updating the plan and stack to unblock future
stack updates. For the ffwd upgrade workflow we have set and
used the config-download Software/Structured Deployment for the
OS::TripleO and OS::Heat resources. This unsets those back to
their default values.
"""
log = logging.getLogger(__name__ + ".FFWDUpgradeConverge")
def get_parser(self, prog_name):
parser = super(FFWDUpgradeConverge, self).get_parser(prog_name)
parser.add_argument('--yes',
action='store_true',
help=_("Use --yes to skip the confirmation "
"required before any ffwd-upgrade "
"operation. Use this with caution! "),
)
return parser
def take_action(self, parsed_args):
self.log.debug("take_action(%s)" % parsed_args)
oooutils.ffwd_upgrade_operator_confirm(parsed_args.yes, self.log)
# Add the converge environment into the args to unset noop etc
templates_dir = (parsed_args.templates or
constants.TRIPLEO_HEAT_TEMPLATES)
if not parsed_args.environment_files:
parsed_args.environment_files = []
parsed_args.environment_files = oooutils.prepend_environment(
parsed_args.environment_files, templates_dir,
constants.FFWD_UPGRADE_CONVERGE_ENV)
super(FFWDUpgradeConverge, self).take_action(parsed_args)
self.log.info("FFWD Upgrade Converge on stack {0} complete.".format(
parsed_args.stack))