From 2e57826a7767a0af8e2c8dbc3f4af6ac4325f01b Mon Sep 17 00:00:00 2001 From: Matt Riedemann Date: Tue, 30 Jul 2019 12:58:39 -0400 Subject: [PATCH] Remove Request Spec Migration upgrade status check The "Request Spec Migration" upgrade status check was added in Rocky [1] and the related online data migration was removed in Stein [2]. Now that we're in Train we should be able to remove the upgrade status check. The verify install docs are updated to remove the now-removed check along with "Console Auths" which were removed in Train [3]. [1] I1fb63765f0b0e8f35d6a66dccf9d12cc20e9c661 [2] Ib0de49b3c0d6b3d807c4eb321976848773c1a9e8 [3] I5c7e54259857d9959f5a2dfb99102602a0cf9bb7 Change-Id: I6dfa0b226ab0b99864fc27209ebb7b73e3f73512 --- doc/source/cli/nova-status.rst | 1 + doc/source/install/verify.rst | 6 +- nova/cmd/status.py | 61 ---------------- nova/tests/unit/cmd/test_status.py | 108 ----------------------------- 4 files changed, 2 insertions(+), 174 deletions(-) diff --git a/doc/source/cli/nova-status.rst b/doc/source/cli/nova-status.rst index c63b5bc3b984..c65541ba5345 100644 --- a/doc/source/cli/nova-status.rst +++ b/doc/source/cli/nova-status.rst @@ -138,6 +138,7 @@ Upgrade If ``[cinder]/auth_type`` is not configured this is a no-op check. * The "**nova-consoleauth** service" upgrade check was removed since the service was removed in Train. + * The ``Request Spec Migration`` check was removed. See Also ======== diff --git a/doc/source/install/verify.rst b/doc/source/install/verify.rst index 98d4b9de21b5..7aaf0b5f8658 100644 --- a/doc/source/install/verify.rst +++ b/doc/source/install/verify.rst @@ -119,11 +119,7 @@ Verify operation of the Compute service. | Result: Success | | Details: None | +--------------------------------------------------------------------+ - | Check: Request Spec Migration | - | Result: Success | - | Details: None | - +--------------------------------------------------------------------+ - | Check: Console Auths | + | Check: Cinder API | | Result: Success | | Details: None | +--------------------------------------------------------------------+ diff --git a/nova/cmd/status.py b/nova/cmd/status.py index c0eaa072542e..05e555fa89fa 100644 --- a/nova/cmd/status.py +++ b/nova/cmd/status.py @@ -327,65 +327,6 @@ class UpgradeCommands(upgradecheck.UpgradeCommands): services.c.deleted == 0, services.c.forced_down == false())).scalar() - def _check_request_spec_migration(self): - """Checks to make sure request spec migrations are complete. - - Iterates all cells checking to see that non-deleted instances have - a matching request spec in the API database. This is necessary in order - to drop the migrate_instances_add_request_spec online data migration - and accompanying compatibility code found through nova-api and - nova-conductor. - """ - meta = MetaData(bind=db_session.get_api_engine()) - mappings = self._get_cell_mappings() - - 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 request spec migrations without ' - 'cell mappings.')) - return upgradecheck.Result(upgradecheck.Code.WARNING, msg) - - request_specs = Table('request_specs', meta, autoload=True) - ctxt = nova_context.get_admin_context() - incomplete_cells = [] # list of cell mapping uuids - for mapping in mappings: - with nova_context.target_cell(ctxt, mapping) as cctxt: - # Get all instance uuids for non-deleted instances in this - # cell. - meta = MetaData(bind=db_session.get_engine(context=cctxt)) - instances = Table('instances', meta, autoload=True) - instance_records = ( - select([instances.c.uuid]).select_from(instances).where( - instances.c.deleted == 0 - ).execute().fetchall()) - # For each instance in the list, verify that it has a matching - # request spec in the API DB. - for inst in instance_records: - spec_id = ( - select([request_specs.c.id]).select_from( - request_specs).where( - request_specs.c.instance_uuid == inst['uuid'] - ).execute().scalar()) - if spec_id is None: - # This cell does not have all of its instances - # migrated for request specs so track it and move on. - incomplete_cells.append(mapping.uuid) - break - - # It's a failure if there are any unmigrated instances at this point - # because we are planning to drop the online data migration routine and - # compatibility code in Stein. - if incomplete_cells: - msg = (_("The following cells have instances which do not have " - "matching request_specs in the API database: %s Run " - "'nova-manage db online_data_migrations' on each cell " - "to create the missing request specs.") % - ', '.join(incomplete_cells)) - return upgradecheck.Result(upgradecheck.Code.FAILURE, msg) - return upgradecheck.Result(upgradecheck.Code.SUCCESS) - def _check_cinder(self): """Checks to see that the cinder API is available at a given minimum microversion. @@ -428,8 +369,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 - (_('Request Spec Migration'), _check_request_spec_migration), # Added in Train (_('Cinder API'), _check_cinder), ) diff --git a/nova/tests/unit/cmd/test_status.py b/nova/tests/unit/cmd/test_status.py index be11c79140e7..b24647cf1640 100644 --- a/nova/tests/unit/cmd/test_status.py +++ b/nova/tests/unit/cmd/test_status.py @@ -39,7 +39,6 @@ from nova import exception # NOTE(mriedem): We only use objects as a convenience to populate the database # in the tests, we don't use them in the actual CLI. from nova import objects -from nova.scheduler import utils as scheduler_utils from nova import test from nova.tests import fixtures as nova_fixtures @@ -510,113 +509,6 @@ class TestUpgradeCheckIronicFlavorMigration(test.NoDBTestCase): result.details) -def _create_minimal_request_spec(ctxt, instance): - request_spec = objects.RequestSpec.from_components( - ctxt, instance.uuid, instance.image_meta, - instance.flavor, instance.numa_topology, - instance.pci_requests, - {}, None, instance.availability_zone, - project_id=instance.project_id, - user_id=instance.user_id - ) - scheduler_utils.setup_instance_group(ctxt, request_spec) - request_spec.create() - - -class TestUpgradeCheckRequestSpecMigration(test.NoDBTestCase): - """Tests for the nova-status upgrade check for request spec migration.""" - - # 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(TestUpgradeCheckRequestSpecMigration, self).setUp() - self.output = StringIO() - self.useFixture(fixtures.MonkeyPatch('sys.stdout', self.output)) - # We always need the API DB to be setup. - self.useFixture(nova_fixtures.Database(database='api')) - self.cmd = status.UpgradeCommands() - - @staticmethod - def _create_instance_in_cell(ctxt, cell, is_deleted=False, - create_request_spec=False): - with context.target_cell(ctxt, cell) as cctxt: - inst = objects.Instance( - context=cctxt, - uuid=uuidutils.generate_uuid()) - inst.create() - - if is_deleted: - inst.destroy() - - if create_request_spec: - # Fake out some fields in the Instance so we don't lazy-load them. - inst.flavor = objects.Flavor() - inst.numa_topology = None - inst.system_metadata = {} - inst.pci_requests = None - inst.project_id = 'fake-project' - inst.user_id = 'fake-user' - _create_minimal_request_spec(ctxt, inst) - - return inst - - def test_fresh_install_no_cell_mappings(self): - """Tests the scenario where we don't have any cell mappings (no cells - v2 setup yet) so we don't know what state we're in and we return a - warning. - """ - result = self.cmd._check_request_spec_migration() - self.assertEqual(upgradecheck.Code.WARNING, result.code) - self.assertIn('Unable to determine request spec migrations without ' - 'cell mappings.', result.details) - - def test_deleted_instance_one_cell_migrated_other_success(self): - """Tests the scenario that we have two cells, one has only a single - deleted instance in it and the other has a single already-migrated - instance in it, so the overall result is success. - """ - self._setup_cells() - ctxt = context.get_admin_context() - - # Create a deleted instance in cell1. - self._create_instance_in_cell( - ctxt, self.cell_mappings['cell1'], is_deleted=True) - - # Create a migrated instance in cell2. - self._create_instance_in_cell( - ctxt, self.cell_mappings['cell2'], create_request_spec=True) - - result = self.cmd._check_request_spec_migration() - self.assertEqual(upgradecheck.Code.SUCCESS, result.code) - - def test_unmigrated_request_spec_instances(self): - """Tests the scenario that we have a migrated instance in cell1 and - an unmigrated instance in cell2 so the check fails. - """ - self._setup_cells() - ctxt = context.get_admin_context() - - # Create a migrated instance in cell1. - self._create_instance_in_cell( - ctxt, self.cell_mappings['cell1'], create_request_spec=True) - - # Create an unmigrated instance in cell2. - self._create_instance_in_cell(ctxt, self.cell_mappings['cell2']) - - result = self.cmd._check_request_spec_migration() - self.assertEqual(upgradecheck.Code.FAILURE, result.code) - self.assertIn("The following cells have instances which do not have " - "matching request_specs in the API database: %s Run " - "'nova-manage db online_data_migrations' on each cell " - "to create the missing request specs." % - self.cell_mappings['cell2'].uuid, result.details) - - class TestUpgradeCheckCinderAPI(test.NoDBTestCase): def setUp(self):