@@ -4803,8 +4803,18 @@ def _finish_revert_snapshot_based_resize_at_source(
4803
4803
self.host, instance=instance)
4804
4804
# TODO(mriedem): Calculate provider mappings when we support
4805
4805
# cross-cell resize/migrate with ports having resource requests.
4806
- self._finish_revert_resize_network_migrate_finish(
4807
- ctxt, instance, migration, provider_mappings=None)
4806
+ # NOTE(hanrong): we need to change migration.dest_compute to
4807
+ # source host temporarily.
4808
+ # "network_api.migrate_instance_finish" will setup the network
4809
+ # for the instance on the destination host. For revert resize,
4810
+ # the instance will back to the source host, the setup of the
4811
+ # network for instance should be on the source host. So set
4812
+ # the migration.dest_compute to source host at here.
4813
+ with utils.temporary_mutation(
4814
+ migration, dest_compute=migration.source_compute
4815
+ ):
4816
+ self.network_api.migrate_instance_finish(
4817
+ ctxt, instance, migration, provider_mappings=None)
4808
4818
network_info = self.network_api.get_instance_nw_info(ctxt, instance)
4809
4819
4810
4820
# Remember that prep_snapshot_based_resize_at_source destroyed the
@@ -4896,50 +4906,6 @@ def revert_resize(self, context, instance, migration, request_spec):
4896
4906
self.compute_rpcapi.finish_revert_resize(context, instance,
4897
4907
migration, migration.source_compute, request_spec)
4898
4908
4899
- def _finish_revert_resize_network_migrate_finish(
4900
- self, context, instance, migration, provider_mappings):
4901
- """Causes port binding to be updated. In some Neutron or port
4902
- configurations - see NetworkModel.get_bind_time_events() - we
4903
- expect the vif-plugged event from Neutron immediately and wait for it.
4904
- The rest of the time, the event is expected further along in the
4905
- virt driver, so we don't wait here.
4906
-
4907
- :param context: The request context.
4908
- :param instance: The instance undergoing the revert resize.
4909
- :param migration: The Migration object of the resize being reverted.
4910
- :param provider_mappings: a dict of list of resource provider uuids
4911
- keyed by port uuid
4912
- :raises: eventlet.timeout.Timeout or
4913
- exception.VirtualInterfacePlugException.
4914
- """
4915
- network_info = instance.get_network_info()
4916
- events = []
4917
- deadline = CONF.vif_plugging_timeout
4918
- if deadline and network_info:
4919
- events = network_info.get_bind_time_events(migration)
4920
- if events:
4921
- LOG.debug('Will wait for bind-time events: %s', events)
4922
- error_cb = self._neutron_failed_migration_callback
4923
- try:
4924
- with self.virtapi.wait_for_instance_event(instance, events,
4925
- deadline=deadline,
4926
- error_callback=error_cb):
4927
- # NOTE(hanrong): we need to change migration.dest_compute to
4928
- # source host temporarily.
4929
- # "network_api.migrate_instance_finish" will setup the network
4930
- # for the instance on the destination host. For revert resize,
4931
- # the instance will back to the source host, the setup of the
4932
- # network for instance should be on the source host. So set
4933
- # the migration.dest_compute to source host at here.
4934
- with utils.temporary_mutation(
4935
- migration, dest_compute=migration.source_compute):
4936
- self.network_api.migrate_instance_finish(
4937
- context, instance, migration, provider_mappings)
4938
- except eventlet.timeout.Timeout:
4939
- with excutils.save_and_reraise_exception():
4940
- LOG.error('Timeout waiting for Neutron events: %s', events,
4941
- instance=instance)
4942
-
4943
4909
@wrap_exception()
4944
4910
@reverts_task_state
4945
4911
@wrap_instance_event(prefix='compute')
@@ -4997,8 +4963,18 @@ def _finish_revert_resize(
4997
4963
4998
4964
self.network_api.setup_networks_on_host(context, instance,
4999
4965
migration.source_compute)
5000
- self._finish_revert_resize_network_migrate_finish(
5001
- context, instance, migration, provider_mappings)
4966
+ # NOTE(hanrong): we need to change migration.dest_compute to
4967
+ # source host temporarily. "network_api.migrate_instance_finish"
4968
+ # will setup the network for the instance on the destination host.
4969
+ # For revert resize, the instance will back to the source host, the
4970
+ # setup of the network for instance should be on the source host.
4971
+ # So set the migration.dest_compute to source host at here.
4972
+ with utils.temporary_mutation(
4973
+ migration, dest_compute=migration.source_compute):
4974
+ self.network_api.migrate_instance_finish(context,
4975
+ instance,
4976
+ migration,
4977
+ provider_mappings)
5002
4978
network_info = self.network_api.get_instance_nw_info(context,
5003
4979
instance)
5004
4980
@@ -5075,8 +5051,7 @@ def _fill_provider_mapping_based_on_allocs(
5075
5051
# the provider mappings. If the instance has ports with
5076
5052
# resource request then the port update will fail in
5077
5053
# _update_port_binding_for_instance() called via
5078
- # _finish_revert_resize_network_migrate_finish() in
5079
- # finish_revert_resize.
5054
+ # migrate_instance_finish() in finish_revert_resize.
5080
5055
provider_mappings = None
5081
5056
return provider_mappings
5082
5057
@@ -8287,8 +8262,8 @@ def pre_live_migration(self, context, instance, disk, migrate_data):
8287
8262
return migrate_data
8288
8263
8289
8264
@staticmethod
8290
- def _neutron_failed_migration_callback (event_name, instance):
8291
- msg = ('Neutron reported failure during migration '
8265
+ def _neutron_failed_live_migration_callback (event_name, instance):
8266
+ msg = ('Neutron reported failure during live migration '
8292
8267
'with %(event)s for instance %(uuid)s')
8293
8268
msg_args = {'event': event_name, 'uuid': instance.uuid}
8294
8269
if CONF.vif_plugging_is_fatal:
@@ -8384,7 +8359,7 @@ class _BreakWaitForInstanceEvent(Exception):
8384
8359
disk = None
8385
8360
8386
8361
deadline = CONF.vif_plugging_timeout
8387
- error_cb = self._neutron_failed_migration_callback
8362
+ error_cb = self._neutron_failed_live_migration_callback
8388
8363
# In order to avoid a race with the vif plugging that the virt
8389
8364
# driver does on the destination host, we register our events
8390
8365
# to wait for before calling pre_live_migration. Then if the
0 commit comments