Merge "Remove "API Service Version" upgrade check"

This commit is contained in:
Zuul 2018-12-24 23:08:59 +00:00 committed by Gerrit Code Review
commit 53a86b50f2
3 changed files with 2 additions and 165 deletions

View File

@ -127,6 +127,8 @@ Upgrade
* The "Resource Providers" upgrade check was removed since the placement
service code is being extracted from nova and the related tables are no
longer used in the ``nova_api`` database.
* The "API Service Version" upgrade check was removed since the corresponding
code for that check was removed in Stein.
See Also
========

View File

@ -299,65 +299,6 @@ class UpgradeCommands(upgradecheck.UpgradeCommands):
services.c.deleted == 0,
services.c.forced_down == false())).scalar()
def _check_api_service_version(self):
"""Checks nova-osapi_compute service versions across cells.
For non-cellsv1 deployments, based on how the [database]/connection
is configured for the nova-api service, the nova-osapi_compute service
versions before 15 will only attempt to lookup instances from the
local database configured for the nova-api service directly.
This can cause issues if there are newer API service versions in cell1
after the upgrade to Ocata, but lingering older API service versions
in an older database.
This check will scan all cells looking for a minimum nova-osapi_compute
service version less than 15 and if found, emit a warning that those
service entries likely need to be cleaned up.
"""
# If we're using cells v1 then we don't care about this.
if CONF.cells.enable:
return upgradecheck.Result(upgradecheck.Code.SUCCESS)
meta = MetaData(bind=db_session.get_api_engine())
cell_mappings = Table('cell_mappings', meta, autoload=True)
mappings = cell_mappings.select().execute().fetchall()
if not mappings:
# There are no cell mappings so we can't determine this, just
# return a warning. The cellsv2 check would have already failed
# on this.
msg = (_('Unable to determine API service versions without '
'cell mappings.'))
return upgradecheck.Result(upgradecheck.Code.WARNING, msg)
ctxt = nova_context.get_admin_context()
cells_with_old_api_services = []
for mapping in mappings:
with nova_context.target_cell(ctxt, mapping) as cctxt:
# Get the minimum nova-osapi_compute service version in this
# cell.
min_version = self._get_min_service_version(
cctxt, 'nova-osapi_compute')
if min_version is not None and min_version < 15:
cells_with_old_api_services.append(mapping['uuid'])
# If there are any cells with older API versions, we report it as a
# warning since we don't know how the actual nova-api service is
# configured, but we need to give the operator some indication that
# they have something to investigate/cleanup.
if cells_with_old_api_services:
msg = (_("The following cells have 'nova-osapi_compute' services "
"with version < 15 which may cause issues when querying "
"instances from the API: %s. Depending on how nova-api "
"is configured, this may not be a problem, but is worth "
"investigating and potentially cleaning up those older "
"records. See "
"https://bugs.launchpad.net/nova/+bug/1759316 for "
"details.") % ', '.join(cells_with_old_api_services))
return upgradecheck.Result(upgradecheck.Code.WARNING, msg)
return upgradecheck.Result(upgradecheck.Code.SUCCESS)
def _check_request_spec_migration(self):
"""Checks to make sure request spec migrations are complete.
@ -513,8 +454,6 @@ class UpgradeCommands(upgradecheck.UpgradeCommands):
(_('Placement API'), _check_placement),
# Added in Rocky (but also useful going back to Pike)
(_('Ironic Flavor Migration'), _check_ironic_flavor_migration),
# Added in Rocky (but is backportable to Ocata)
(_('API Service Version'), _check_api_service_version),
# Added in Rocky
(_('Request Spec Migration'), _check_request_spec_migration),
# Added in Stein (but also useful going back to Rocky)

View File

@ -509,110 +509,6 @@ class TestUpgradeCheckIronicFlavorMigration(test.NoDBTestCase):
result.details)
class TestUpgradeCheckAPIServiceVersion(test.NoDBTestCase):
"""Tests for the nova-status upgrade API service version specific check."""
# We'll setup the database ourselves because we need to use cells fixtures
# for multiple cell mappings.
USES_DB_SELF = True
# This will create three cell mappings: cell0, cell1 (default) and cell2
NUMBER_OF_CELLS = 2
def setUp(self):
super(TestUpgradeCheckAPIServiceVersion, self).setUp()
self.output = StringIO()
self.useFixture(fixtures.MonkeyPatch('sys.stdout', self.output))
self.useFixture(nova_fixtures.Database(database='api'))
self.cmd = status.UpgradeCommands()
def test_check_cells_v1_enabled(self):
"""This is a 'success' case since the API service version check is
ignored when running cells v1.
"""
self.flags(enable=True, group='cells')
result = self.cmd._check_api_service_version()
self.assertEqual(upgradecheck.Code.SUCCESS, result.code)
def test_check_no_cell_mappings_warning(self):
"""Warn when there are no cell mappings."""
result = self.cmd._check_api_service_version()
self.assertEqual(upgradecheck.Code.WARNING, result.code)
self.assertEqual('Unable to determine API service versions without '
'cell mappings.', result.details)
@staticmethod
def _create_service(ctxt, host, binary, version):
svc = objects.Service(ctxt, host=host, binary=binary)
svc.version = version
svc.create()
return svc
def test_check_warning(self):
"""This is a failure scenario where we have the following setup:
Three cells where:
1. The first cell has two API services, one with version < 15 and one
with version >= 15.
2. The second cell has two services, one with version < 15 but it's
deleted so it gets filtered out, and one with version >= 15.
3. The third cell doesn't have any API services, just old compute
services which should be filtered out.
In this scenario, the first cell should be reported with a warning.
"""
self._setup_cells()
ctxt = context.get_admin_context()
cell0 = self.cell_mappings['cell0']
with context.target_cell(ctxt, cell0) as cctxt:
self._create_service(cctxt, host='cell0host1',
binary='nova-osapi_compute', version=14)
self._create_service(cctxt, host='cell0host2',
binary='nova-osapi_compute', version=15)
cell1 = self.cell_mappings['cell1']
with context.target_cell(ctxt, cell1) as cctxt:
svc = self._create_service(
cctxt, host='cell1host1', binary='nova-osapi_compute',
version=14)
# This deleted record with the old version should get filtered out.
svc.destroy()
self._create_service(cctxt, host='cell1host2',
binary='nova-osapi_compute', version=16)
cell2 = self.cell_mappings['cell2']
with context.target_cell(ctxt, cell2) as cctxt:
self._create_service(cctxt, host='cell2host1',
binary='nova-compute', version=14)
result = self.cmd._check_api_service_version()
self.assertEqual(upgradecheck.Code.WARNING, result.code)
# The only cell in the message should be cell0.
self.assertIn(cell0.uuid, result.details)
self.assertNotIn(cell1.uuid, result.details)
self.assertNotIn(cell2.uuid, result.details)
def test_check_success(self):
"""Tests the success scenario where we have cell0 with a current API
service, cell1 with no API services, and an empty cell2.
"""
self._setup_cells()
ctxt = context.get_admin_context()
cell0 = self.cell_mappings['cell0']
with context.target_cell(ctxt, cell0) as cctxt:
self._create_service(cctxt, host='cell0host1',
binary='nova-osapi_compute', version=15)
cell1 = self.cell_mappings['cell1']
with context.target_cell(ctxt, cell1) as cctxt:
self._create_service(cctxt, host='cell1host1',
binary='nova-compute', version=15)
result = self.cmd._check_api_service_version()
self.assertEqual(upgradecheck.Code.SUCCESS, result.code)
def _create_minimal_request_spec(ctxt, instance):
request_spec = objects.RequestSpec.from_components(
ctxt, instance.uuid, instance.image_meta,