@@ -4803,8 +4803,18 @@ def _finish_revert_snapshot_based_resize_at_source(
48034803 self.host, instance=instance)
48044804 # TODO(mriedem): Calculate provider mappings when we support
48054805 # 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)
48084818 network_info = self.network_api.get_instance_nw_info(ctxt, instance)
48094819
48104820 # Remember that prep_snapshot_based_resize_at_source destroyed the
@@ -4896,50 +4906,6 @@ def revert_resize(self, context, instance, migration, request_spec):
48964906 self.compute_rpcapi.finish_revert_resize(context, instance,
48974907 migration, migration.source_compute, request_spec)
48984908
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-
49434909 @wrap_exception()
49444910 @reverts_task_state
49454911 @wrap_instance_event(prefix='compute')
@@ -4997,8 +4963,18 @@ def _finish_revert_resize(
49974963
49984964 self.network_api.setup_networks_on_host(context, instance,
49994965 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)
50024978 network_info = self.network_api.get_instance_nw_info(context,
50034979 instance)
50044980
@@ -5075,8 +5051,7 @@ def _fill_provider_mapping_based_on_allocs(
50755051 # the provider mappings. If the instance has ports with
50765052 # resource request then the port update will fail in
50775053 # _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.
50805055 provider_mappings = None
50815056 return provider_mappings
50825057
@@ -8287,8 +8262,8 @@ def pre_live_migration(self, context, instance, disk, migrate_data):
82878262 return migrate_data
82888263
82898264 @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 '
82928267 'with %(event)s for instance %(uuid)s')
82938268 msg_args = {'event': event_name, 'uuid': instance.uuid}
82948269 if CONF.vif_plugging_is_fatal:
@@ -8384,7 +8359,7 @@ class _BreakWaitForInstanceEvent(Exception):
83848359 disk = None
83858360
83868361 deadline = CONF.vif_plugging_timeout
8387- error_cb = self._neutron_failed_migration_callback
8362+ error_cb = self._neutron_failed_live_migration_callback
83888363 # In order to avoid a race with the vif plugging that the virt
83898364 # driver does on the destination host, we register our events
83908365 # to wait for before calling pre_live_migration. Then if the
0 commit comments