@@ -4809,8 +4809,18 @@ def _finish_revert_snapshot_based_resize_at_source(
4809
4809
self.host, instance=instance)
4810
4810
# TODO(mriedem): Calculate provider mappings when we support
4811
4811
# cross-cell resize/migrate with ports having resource requests.
4812
- self._finish_revert_resize_network_migrate_finish(
4813
- ctxt, instance, migration, provider_mappings=None)
4812
+ # NOTE(hanrong): we need to change migration.dest_compute to
4813
+ # source host temporarily.
4814
+ # "network_api.migrate_instance_finish" will setup the network
4815
+ # for the instance on the destination host. For revert resize,
4816
+ # the instance will back to the source host, the setup of the
4817
+ # network for instance should be on the source host. So set
4818
+ # the migration.dest_compute to source host at here.
4819
+ with utils.temporary_mutation(
4820
+ migration, dest_compute=migration.source_compute
4821
+ ):
4822
+ self.network_api.migrate_instance_finish(
4823
+ ctxt, instance, migration, provider_mappings=None)
4814
4824
network_info = self.network_api.get_instance_nw_info(ctxt, instance)
4815
4825
4816
4826
# Remember that prep_snapshot_based_resize_at_source destroyed the
@@ -4902,50 +4912,6 @@ def revert_resize(self, context, instance, migration, request_spec):
4902
4912
self.compute_rpcapi.finish_revert_resize(context, instance,
4903
4913
migration, migration.source_compute, request_spec)
4904
4914
4905
- def _finish_revert_resize_network_migrate_finish(
4906
- self, context, instance, migration, provider_mappings):
4907
- """Causes port binding to be updated. In some Neutron or port
4908
- configurations - see NetworkModel.get_bind_time_events() - we
4909
- expect the vif-plugged event from Neutron immediately and wait for it.
4910
- The rest of the time, the event is expected further along in the
4911
- virt driver, so we don't wait here.
4912
-
4913
- :param context: The request context.
4914
- :param instance: The instance undergoing the revert resize.
4915
- :param migration: The Migration object of the resize being reverted.
4916
- :param provider_mappings: a dict of list of resource provider uuids
4917
- keyed by port uuid
4918
- :raises: eventlet.timeout.Timeout or
4919
- exception.VirtualInterfacePlugException.
4920
- """
4921
- network_info = instance.get_network_info()
4922
- events = []
4923
- deadline = CONF.vif_plugging_timeout
4924
- if deadline and network_info:
4925
- events = network_info.get_bind_time_events(migration)
4926
- if events:
4927
- LOG.debug('Will wait for bind-time events: %s', events)
4928
- error_cb = self._neutron_failed_migration_callback
4929
- try:
4930
- with self.virtapi.wait_for_instance_event(instance, events,
4931
- deadline=deadline,
4932
- error_callback=error_cb):
4933
- # NOTE(hanrong): we need to change migration.dest_compute to
4934
- # source host temporarily.
4935
- # "network_api.migrate_instance_finish" will setup the network
4936
- # for the instance on the destination host. For revert resize,
4937
- # the instance will back to the source host, the setup of the
4938
- # network for instance should be on the source host. So set
4939
- # the migration.dest_compute to source host at here.
4940
- with utils.temporary_mutation(
4941
- migration, dest_compute=migration.source_compute):
4942
- self.network_api.migrate_instance_finish(
4943
- context, instance, migration, provider_mappings)
4944
- except eventlet.timeout.Timeout:
4945
- with excutils.save_and_reraise_exception():
4946
- LOG.error('Timeout waiting for Neutron events: %s', events,
4947
- instance=instance)
4948
-
4949
4915
@wrap_exception()
4950
4916
@reverts_task_state
4951
4917
@wrap_instance_event(prefix='compute')
@@ -5003,8 +4969,18 @@ def _finish_revert_resize(
5003
4969
5004
4970
self.network_api.setup_networks_on_host(context, instance,
5005
4971
migration.source_compute)
5006
- self._finish_revert_resize_network_migrate_finish(
5007
- context, instance, migration, provider_mappings)
4972
+ # NOTE(hanrong): we need to change migration.dest_compute to
4973
+ # source host temporarily. "network_api.migrate_instance_finish"
4974
+ # will setup the network for the instance on the destination host.
4975
+ # For revert resize, the instance will back to the source host, the
4976
+ # setup of the network for instance should be on the source host.
4977
+ # So set the migration.dest_compute to source host at here.
4978
+ with utils.temporary_mutation(
4979
+ migration, dest_compute=migration.source_compute):
4980
+ self.network_api.migrate_instance_finish(context,
4981
+ instance,
4982
+ migration,
4983
+ provider_mappings)
5008
4984
network_info = self.network_api.get_instance_nw_info(context,
5009
4985
instance)
5010
4986
@@ -5081,8 +5057,7 @@ def _fill_provider_mapping_based_on_allocs(
5081
5057
# the provider mappings. If the instance has ports with
5082
5058
# resource request then the port update will fail in
5083
5059
# _update_port_binding_for_instance() called via
5084
- # _finish_revert_resize_network_migrate_finish() in
5085
- # finish_revert_resize.
5060
+ # migrate_instance_finish() in finish_revert_resize.
5086
5061
provider_mappings = None
5087
5062
return provider_mappings
5088
5063
@@ -8306,8 +8281,8 @@ def pre_live_migration(self, context, instance, disk, migrate_data):
8306
8281
return migrate_data
8307
8282
8308
8283
@staticmethod
8309
- def _neutron_failed_migration_callback (event_name, instance):
8310
- msg = ('Neutron reported failure during migration '
8284
+ def _neutron_failed_live_migration_callback (event_name, instance):
8285
+ msg = ('Neutron reported failure during live migration '
8311
8286
'with %(event)s for instance %(uuid)s')
8312
8287
msg_args = {'event': event_name, 'uuid': instance.uuid}
8313
8288
if CONF.vif_plugging_is_fatal:
@@ -8403,7 +8378,7 @@ class _BreakWaitForInstanceEvent(Exception):
8403
8378
disk = None
8404
8379
8405
8380
deadline = CONF.vif_plugging_timeout
8406
- error_cb = self._neutron_failed_migration_callback
8381
+ error_cb = self._neutron_failed_live_migration_callback
8407
8382
# In order to avoid a race with the vif plugging that the virt
8408
8383
# driver does on the destination host, we register our events
8409
8384
# to wait for before calling pre_live_migration. Then if the
0 commit comments