diff --git a/nova/compute/manager.py b/nova/compute/manager.py index f983fb47fba7..dfa0138ab166 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -673,7 +673,7 @@ class ComputeVirtAPI(virtapi.VirtAPI): class ComputeManager(manager.Manager): """Manages the running instances from creation to destruction.""" - target = messaging.Target(version='4.10') + target = messaging.Target(version='4.11') # How long to wait in seconds before re-issuing a shutdown # signal to an instance during power off. The overall @@ -5050,7 +5050,9 @@ class ComputeManager(manager.Manager): :param context: security context :param instance: dict of instance data :param block_migration: if true, prepare for block migration + if None, calculate it in driver :param disk_over_commit: if true, allow disk over commit + if None, ignore disk usage checking :returns: a dict containing migration info """ return self._do_check_can_live_migrate_destination(ctxt, instance, diff --git a/nova/compute/rpcapi.py b/nova/compute/rpcapi.py index f78a307b5241..af4125247edf 100644 --- a/nova/compute/rpcapi.py +++ b/nova/compute/rpcapi.py @@ -327,6 +327,7 @@ class ComputeAPI(object): * ... - Remove refresh_provider_fw_rules() * 4.9 - Add live_migration_force_complete() * 4.10 - Add live_migration_abort() + * 4.11 - Allow block_migration and disk_over_commit be None ''' VERSION_ALIASES = { @@ -435,7 +436,18 @@ class ComputeAPI(object): def check_can_live_migrate_destination(self, ctxt, instance, destination, block_migration, disk_over_commit): - version = '4.0' + version = '4.11' + if not self.client.can_send_version(version): + # NOTE(eliqiao): This is a new feature that is only available + # once all compute nodes support at least version 4.11. + # This means the new REST API that supports this needs to handle + # this exception correctly. This can all be removed when we bump + # the major version of this RPC API. + if block_migration is None or disk_over_commit is None: + raise exception.LiveMigrationWithOldNovaNotSupported() + else: + version = '4.0' + cctxt = self.client.prepare(server=destination, version=version) result = cctxt.call(ctxt, 'check_can_live_migrate_destination', instance=instance, diff --git a/nova/exception.py b/nova/exception.py index 23c3c6eb7b43..837c2a5ecc11 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -1857,6 +1857,11 @@ class LiveMigrationWithOldNovaNotSafe(NovaException): "Upgrade Nova on %(server)s and try again.") +class LiveMigrationWithOldNovaNotSupported(NovaException): + msg_fmt = _("Live migration with API v2.25 requires all the Mitaka " + "upgrade to be complete before it is available.") + + class LiveMigrationURINotAvailable(NovaException): msg_fmt = _('No live migration URI configured and no default available ' 'for "%(virt_type)s" hypervisor virtualization type.') diff --git a/nova/objects/service.py b/nova/objects/service.py index 15062a8d447e..38b7b67baa07 100644 --- a/nova/objects/service.py +++ b/nova/objects/service.py @@ -29,7 +29,7 @@ LOG = logging.getLogger(__name__) # NOTE(danms): This is the global service version counter -SERVICE_VERSION = 8 +SERVICE_VERSION = 9 # NOTE(danms): This is our SERVICE_VERSION history. The idea is that any @@ -69,6 +69,8 @@ SERVICE_VERSION_HISTORY = ( {'compute_rpc': '4.9'}, # Version 8: Add live_migration_abort in the compute_rpc {'compute_rpc': '4.10'}, + # Version 9: Allow block_migration and disk_over_commit be None + {'compute_rpc': '4.11'}, ) diff --git a/nova/tests/unit/compute/test_rpcapi.py b/nova/tests/unit/compute/test_rpcapi.py index 54af080d9150..ff3f0f239536 100644 --- a/nova/tests/unit/compute/test_rpcapi.py +++ b/nova/tests/unit/compute/test_rpcapi.py @@ -666,3 +666,13 @@ class ComputeRpcAPITestCase(test.NoDBTestCase): 'migrate_data': {}}, callret=None, calltype='cast') + + def test_check_can_live_migrate_destination_old_compute(self): + self.flags(compute='4.10', group='upgrade_levels') + self.assertRaises(exception.LiveMigrationWithOldNovaNotSupported, + self._test_compute_api, + 'check_can_live_migrate_destination', 'call', + instance=self.fake_instance_obj, + block_migration=None, + destination='dest', + disk_over_commit=None, version='4.11')