Skip to content

Commit af3d43d

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Revert "Revert resize: wait for events according to hybrid plug"" into stable/xena
2 parents e35d95f + c3ebe0f commit af3d43d

File tree

10 files changed

+52
-286
lines changed

10 files changed

+52
-286
lines changed

.zuul.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -605,8 +605,7 @@
605605
- nova-lvm
606606
- nova-multi-cell
607607
- nova-next
608-
- nova-ovs-hybrid-plug:
609-
voting: false
608+
- nova-ovs-hybrid-plug
610609
- nova-tox-validate-backport:
611610
voting: false
612611
- nova-tox-functional-centos8-py36

nova/compute/manager.py

Lines changed: 28 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -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

nova/network/model.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -478,17 +478,6 @@ def labeled_ips(self):
478478
'ips': ips}
479479
return []
480480

481-
def has_bind_time_event(self, migration):
482-
"""Returns whether this VIF's network-vif-plugged external event will
483-
be sent by Neutron at "bind-time" - in other words, as soon as the port
484-
binding is updated. This is in the context of updating the port binding
485-
to a host that already has the instance in a shutoff state - in
486-
practice, this means reverting either a cold migration or a
487-
non-same-host resize.
488-
"""
489-
return (self.is_hybrid_plug_enabled() and not
490-
migration.is_same_host())
491-
492481
@property
493482
def has_live_migration_plug_time_event(self):
494483
"""Returns whether this VIF's network-vif-plugged external event will
@@ -557,27 +546,13 @@ def wait(self, do_raise=True):
557546
def json(self):
558547
return jsonutils.dumps(self)
559548

560-
def get_bind_time_events(self, migration):
561-
"""Returns a list of external events for any VIFs that have
562-
"bind-time" events during cold migration.
563-
"""
564-
return [('network-vif-plugged', vif['id'])
565-
for vif in self if vif.has_bind_time_event(migration)]
566-
567549
def get_live_migration_plug_time_events(self):
568550
"""Returns a list of external events for any VIFs that have
569551
"plug-time" events during live migration.
570552
"""
571553
return [('network-vif-plugged', vif['id'])
572554
for vif in self if vif.has_live_migration_plug_time_event]
573555

574-
def get_plug_time_events(self, migration):
575-
"""Returns a list of external events for any VIFs that have
576-
"plug-time" events during cold migration.
577-
"""
578-
return [('network-vif-plugged', vif['id'])
579-
for vif in self if not vif.has_bind_time_event(migration)]
580-
581556
def has_port_with_allocation(self):
582557
return any(vif.has_allocation() for vif in self)
583558

nova/objects/migration.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,6 @@ def instance(self):
202202
def instance(self, instance):
203203
self._cached_instance = instance
204204

205-
def is_same_host(self):
206-
return self.source_compute == self.dest_compute
207-
208205
@property
209206
def is_live_migration(self):
210207
return self.migration_type == fields.MigrationType.LIVE_MIGRATION

nova/tests/unit/compute/test_compute.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5801,9 +5801,7 @@ def fake_finish_revert_migration_driver(*args, **kwargs):
58015801
old_vm_state = vm_states.ACTIVE
58025802
else:
58035803
old_vm_state = vm_states.STOPPED
5804-
params = {'vm_state': old_vm_state,
5805-
'info_cache': objects.InstanceInfoCache(
5806-
network_info=network_model.NetworkInfo([]))}
5804+
params = {'vm_state': old_vm_state}
58075805
instance = self._create_fake_instance_obj(params)
58085806
request_spec = objects.RequestSpec()
58095807

@@ -5956,9 +5954,7 @@ def test_finish_revert_resize_validate_source_compute(self):
59565954
def fake(*args, **kwargs):
59575955
pass
59585956

5959-
params = {'info_cache': objects.InstanceInfoCache(
5960-
network_info=network_model.NetworkInfo([]))}
5961-
instance = self._create_fake_instance_obj(params)
5957+
instance = self._create_fake_instance_obj()
59625958
request_spec = objects.RequestSpec()
59635959

59645960
self.stub_out('nova.virt.fake.FakeDriver.finish_migration', fake)

0 commit comments

Comments
 (0)