Merge "Drop obsolete `overcloud ceph-upgrade run`"

This commit is contained in:
Zuul 2018-08-06 11:37:57 +00:00 committed by Gerrit Code Review
commit 39ab0458ac
7 changed files with 9 additions and 268 deletions

View File

@ -0,0 +1,9 @@
---
upgrade:
- |
The `openstack overcloud ceph-upgrade run` command no longer works
in Rocky due to internal changes to TripleO (more direct execution
of Ansible). The command has been removed from the CLI. Ceph
update/upgrade in Rocky is meant to be performed via `openstack
overcloud external-update run` and `openstack overcloud
external-upgrade run` commands, respectively.

View File

@ -93,7 +93,6 @@ openstack.tripleoclient.v1 =
overcloud_upgrade_converge = tripleoclient.v1.overcloud_upgrade:UpgradeConvergeOvercloud overcloud_upgrade_converge = tripleoclient.v1.overcloud_upgrade:UpgradeConvergeOvercloud
overcloud_external-update_run = tripleoclient.v1.overcloud_external_update:ExternalUpdateRun overcloud_external-update_run = tripleoclient.v1.overcloud_external_update:ExternalUpdateRun
overcloud_external-upgrade_run = tripleoclient.v1.overcloud_external_upgrade:ExternalUpgradeRun overcloud_external-upgrade_run = tripleoclient.v1.overcloud_external_upgrade:ExternalUpgradeRun
overcloud_ceph-upgrade_run = tripleoclient.v1.overcloud_ceph_upgrade:CephUpgrade
overcloud_ffwd-upgrade_prepare = tripleoclient.v1.overcloud_ffwd_upgrade:FFWDUpgradePrepare overcloud_ffwd-upgrade_prepare = tripleoclient.v1.overcloud_ffwd_upgrade:FFWDUpgradePrepare
overcloud_ffwd-upgrade_run = tripleoclient.v1.overcloud_ffwd_upgrade:FFWDUpgradeRun overcloud_ffwd-upgrade_run = tripleoclient.v1.overcloud_ffwd_upgrade:FFWDUpgradeRun
overcloud_ffwd-upgrade_converge = tripleoclient.v1.overcloud_ffwd_upgrade:FFWDUpgradeConverge overcloud_ffwd-upgrade_converge = tripleoclient.v1.overcloud_ffwd_upgrade:FFWDUpgradeConverge

View File

@ -43,7 +43,6 @@ PUPPET_BASE = "/etc/puppet/"
UPDATE_QUEUE = 'update' UPDATE_QUEUE = 'update'
UPGRADE_QUEUE = 'upgrade' UPGRADE_QUEUE = 'upgrade'
FFWD_UPGRADE_QUEUE = 'ffwdupgrade' FFWD_UPGRADE_QUEUE = 'ffwdupgrade'
CEPH_UPGRADE_QUEUE = 'cephupgrade'
EXTERNAL_UPDATE_QUEUE = 'externalupdate' EXTERNAL_UPDATE_QUEUE = 'externalupdate'
EXTERNAL_UPGRADE_QUEUE = 'externalupgrade' EXTERNAL_UPGRADE_QUEUE = 'externalupgrade'
STACK_TIMEOUT = 240 STACK_TIMEOUT = 240
@ -72,7 +71,6 @@ FFWD_UPGRADE_CONVERGE_ENV = "environments/lifecycle/ffwd-upgrade-converge.yaml"
FFWD_UPGRADE_PREPARE_SCRIPT = ("#!/bin/bash \n" FFWD_UPGRADE_PREPARE_SCRIPT = ("#!/bin/bash \n"
"rm -f /usr/libexec/os-apply-config/templates/" "rm -f /usr/libexec/os-apply-config/templates/"
"etc/os-net-config/config.json || true \n") "etc/os-net-config/config.json || true \n")
CEPH_UPGRADE_PREPARE_ENV = "environments/lifecycle/ceph-upgrade-prepare.yaml"
ENABLE_SSH_ADMIN_TIMEOUT = 300 ENABLE_SSH_ADMIN_TIMEOUT = 300
ENABLE_SSH_ADMIN_STATUS_INTERVAL = 5 ENABLE_SSH_ADMIN_STATUS_INTERVAL = 5

View File

@ -1,62 +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 import utils
from tripleoclient.tests import fakes
class FakeClientWrapper(object):
def __init__(self):
self._instance = mock.Mock()
self.object_store = FakeObjectClient()
def messaging_websocket(self):
return fakes.FakeWebSocket()
class FakeObjectClient(object):
def __init__(self):
self._instance = mock.Mock()
self.put_object = mock.Mock()
def get_object(self, *args):
return
class TestCephUpgrade(utils.TestCommand):
def setUp(self):
super(TestCephUpgrade, self).setUp()
self.app.client_manager.auth_ref = mock.Mock(auth_token="TOKEN")
self.app.client_manager.baremetal = mock.Mock()
self.app.client_manager.orchestration = mock.Mock()
self.app.client_manager.tripleoclient = FakeClientWrapper()
self.app.client_manager.workflow_engine = mock.Mock()
class TestCephUpgradeConverge(utils.TestCommand):
def setUp(self):
super(TestCephUpgradeConverge, self).setUp()
self.app.client_manager.auth_ref = mock.Mock(auth_token="TOKEN")
self.app.client_manager.orchestration = mock.Mock()
self.app.client_manager.tripleoclient = FakeClientWrapper()
self.app.client_manager.workflow_engine = mock.Mock()

View File

@ -1,118 +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_ceph_upgrade import fakes
from tripleoclient.v1 import overcloud_ceph_upgrade
class TestCephUpgrade(fakes.TestCephUpgrade):
def setUp(self):
super(TestCephUpgrade, self).setUp()
# Get the command object to test
self.app_args = mock.Mock()
self.app_args.verbose_level = 1
self.cmd = overcloud_ceph_upgrade.CephUpgrade(self.app, self.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.load_container_registry')
@mock.patch('tripleoclient.utils.get_stack')
@mock.patch('tripleoclient.workflows.package_update.update', autospec=True)
@mock.patch(
'tripleoclient.v1.overcloud_ceph_upgrade.DeployOvercloud.take_action')
def test_ceph_upgrade(self, mock_deploy, mock_ceph_upgrade, mock_get_stack,
mock_load_registry):
# get a fresh cmd so that the superclass mock takes effect
cmd = overcloud_ceph_upgrade.CephUpgrade(self.app, self.app_args)
mock_stack = mock.Mock()
mock_stack.stack_name = 'mystack'
mock_get_stack.return_value = mock_stack
mock_load_registry.return_value = {'fake_container': 'fake_value'}
argslist = ['--stack', 'mystack', '--templates',
'--container-registry-file', 'my-fake-registry.yaml']
verifylist = [
('stack', 'mystack'),
('templates', constants.TRIPLEO_HEAT_TEMPLATES),
('container_registry_file', 'my-fake-registry.yaml')
]
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
cmd.take_action(parsed_args)
mock_deploy.assert_called_once_with(parsed_args)
mock_ceph_upgrade.assert_called_once_with(
self.app.client_manager,
container='mystack',
container_registry={'fake_container': 'fake_value'},
ceph_ansible_playbook='/usr/share/ceph-ansible'
'/infrastructure-playbooks'
'/rolling_update.yml',
)
@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.load')
@mock.patch('shutil.copytree', autospec=True)
@mock.patch(
'tripleoclient.v1.overcloud_ceph_upgrade.DeployOvercloud.take_action')
def test_ceph_upgrade_failed(
self, mock_deploy, mock_copy, mock_yaml, mock_abspath, mock_open,
mock_ceph_upgrade, mock_prepend_env):
mock_ceph_upgrade.side_effect = exceptions.DeploymentError()
mock_abspath.return_value = '/home/fake/my-fake-registry.yaml'
mock_yaml.return_value = {'fake_container': 'fake_value'}
argslist = ['--stack', 'overcloud', '--templates',
'--container-registry-file', 'my-fake-registry.yaml']
verifylist = [
('stack', 'overcloud'),
('templates', constants.TRIPLEO_HEAT_TEMPLATES),
('container_registry_file', 'my-fake-registry.yaml')
]
parsed_args = self.check_parser(self.cmd, argslist, verifylist)
# get a fresh cmd so that the superclass mock takes effect
cmd = overcloud_ceph_upgrade.CephUpgrade(self.app, self.app_args)
self.assertRaises(exceptions.DeploymentError,
cmd.take_action, parsed_args)
@mock.patch('tripleoclient.workflows.package_update.update_ansible',
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 = ["--nodes", "controller-1", "--roles", "foo"]
verifylist = []
self.assertRaises(ParserException, lambda: self.check_parser(
self.cmd, argslist, verifylist))

View File

@ -1,85 +0,0 @@
# Copyright 2015 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 tripleoclient import constants
from tripleoclient import utils as oooutils
from tripleoclient.v1.overcloud_deploy import DeployOvercloud
from tripleoclient.workflows import package_update
CONF = cfg.CONF
logging.register_options(CONF)
logging.setup(CONF, '')
class CephUpgrade(DeployOvercloud):
"""Run heat stack update for overcloud nodes to run Ceph upgrade."""
log = logging.getLogger(__name__ + ".CephUpgrade")
def get_parser(self, prog_name):
parser = super(CephUpgrade, self).get_parser(prog_name)
parser.add_argument('--container-registry-file',
dest='container_registry_file',
default=None,
help=_("Optional path to file with container "
"registry data for the update"),
)
parser.add_argument('--ceph-ansible-playbook',
action="store",
default="/usr/share/ceph-ansible"
"/infrastructure-playbooks"
"/rolling_update.yml",
help=_('Path to switch the ceph-ansible playbook '
'used for update. '))
return parser
def take_action(self, parsed_args):
self.log.debug("take_action(%s)" % parsed_args)
clients = self.app.client_manager
stack = oooutils.get_stack(clients.orchestration,
parsed_args.stack)
stack_name = stack.stack_name
registry = oooutils.load_container_registry(
self.log, parsed_args.container_registry_file)
# Run update
ceph_ansible_playbook = parsed_args.ceph_ansible_playbook
# Run Overcloud deploy (stack update)
# In case of update and upgrade we need to force the
# update_plan_only. The heat stack update is done by the
# package_update mistral action
parsed_args.update_plan_only = True
# Add the upgrade-prepare.yaml environment to set noops etc
templates_dir = (parsed_args.templates or
constants.TRIPLEO_HEAT_TEMPLATES)
parsed_args.environment_files = oooutils.prepend_environment(
parsed_args.environment_files, templates_dir,
constants.CEPH_UPGRADE_PREPARE_ENV)
super(CephUpgrade, self).take_action(parsed_args)
package_update.update(clients, container=stack_name,
container_registry=registry,
ceph_ansible_playbook=ceph_ansible_playbook)
package_update.get_config(clients, container=stack_name)
self.log.info("Ceph Upgrade on stack {0} complete.".format(
parsed_args.stack))