Skip to content

Commit 0b0f40d

Browse files
notartomDmitrii Shcherbakov
authored andcommitted
Revert "Revert resize: wait for events according to hybrid plug"
This reverts commit 7a7a223. That commit was added because - tl'dr - upon revert resize, Neutron with the OVS backend and the iptables security group driver would send us the network-vif-plugged event as soon as we updated the port binding. That behaviour has changed with commit 66c7f00. With that commit, we started unplugging the vifs on the source compute host when doing a resize. When reverting the resize, the vifs had to be re-plugged again, regarldess of the networking backend in use. This renders commit 7a7a223. pointless, and it can be reverted. Conflicts - most have to do with context around this commit's code: nova/compute/manager.py a2984b6 added provider_mappings to _finish_revert_resize_network_migrate_finish()'s signature 750aef5 started using _finish_revert_resize_network_migrate_finish() in _finish_revert_snapshot_based_resize_at_source() nova/network/model.py 8b33ac0 added get_live_migration_plug_time_events() and has_live_migration_plug_time_event() 7da9444 added has_port_with_allocation() nova/objects/migration.py f203da3 added is_resize() and is_live_migration() nova/tests/unit/compute/test_compute.py a0e60fe added request_spec to the test nova/tests/unit/compute/test_compute_mgr.py be27800 added unit tests below ours nova/tests/unit/network/test_network_info.py 7da9444 (again) added tests for has_port_with_allocation() nova/tests/unit/virt/libvirt/test_driver.py and nova/virt/libvirt/driver.py are different in that attempting to identify individual conflicts is a pointless exercise, as so much has changed (mdev, vtmp, the recent wait for events during hard reboot workaround config option, etc). They can be treated as manual removal of any code that had to do with the bind-time events logic (though guided by the conflict markers in git). TODO(artom) There was a follow up commit, 78a08d4, that added the migration parameter to finish_revert_migration(). This is no longer needed, as the migration was only used to obtain plug-time events. We'll have to undo that as well. Closes-bug: 1952003 Change-Id: I3cb39a9ec2c260f422b3c48122b9db512cdd799b
1 parent ded6168 commit 0b0f40d

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
@@ -4809,8 +4809,18 @@ def _finish_revert_snapshot_based_resize_at_source(
48094809
self.host, instance=instance)
48104810
# TODO(mriedem): Calculate provider mappings when we support
48114811
# 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)
48144824
network_info = self.network_api.get_instance_nw_info(ctxt, instance)
48154825

48164826
# Remember that prep_snapshot_based_resize_at_source destroyed the
@@ -4902,50 +4912,6 @@ def revert_resize(self, context, instance, migration, request_spec):
49024912
self.compute_rpcapi.finish_revert_resize(context, instance,
49034913
migration, migration.source_compute, request_spec)
49044914

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-
49494915
@wrap_exception()
49504916
@reverts_task_state
49514917
@wrap_instance_event(prefix='compute')
@@ -5003,8 +4969,18 @@ def _finish_revert_resize(
50034969

50044970
self.network_api.setup_networks_on_host(context, instance,
50054971
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)
50084984
network_info = self.network_api.get_instance_nw_info(context,
50094985
instance)
50104986

@@ -5081,8 +5057,7 @@ def _fill_provider_mapping_based_on_allocs(
50815057
# the provider mappings. If the instance has ports with
50825058
# resource request then the port update will fail in
50835059
# _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.
50865061
provider_mappings = None
50875062
return provider_mappings
50885063

@@ -8306,8 +8281,8 @@ def pre_live_migration(self, context, instance, disk, migrate_data):
83068281
return migrate_data
83078282

83088283
@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 '
83118286
'with %(event)s for instance %(uuid)s')
83128287
msg_args = {'event': event_name, 'uuid': instance.uuid}
83138288
if CONF.vif_plugging_is_fatal:
@@ -8403,7 +8378,7 @@ class _BreakWaitForInstanceEvent(Exception):
84038378
disk = None
84048379

84058380
deadline = CONF.vif_plugging_timeout
8406-
error_cb = self._neutron_failed_migration_callback
8381+
error_cb = self._neutron_failed_live_migration_callback
84078382
# In order to avoid a race with the vif plugging that the virt
84088383
# driver does on the destination host, we register our events
84098384
# 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
@@ -485,17 +485,6 @@ def labeled_ips(self):
485485
'ips': ips}
486486
return []
487487

488-
def has_bind_time_event(self, migration):
489-
"""Returns whether this VIF's network-vif-plugged external event will
490-
be sent by Neutron at "bind-time" - in other words, as soon as the port
491-
binding is updated. This is in the context of updating the port binding
492-
to a host that already has the instance in a shutoff state - in
493-
practice, this means reverting either a cold migration or a
494-
non-same-host resize.
495-
"""
496-
return (self.is_hybrid_plug_enabled() and not
497-
migration.is_same_host())
498-
499488
@property
500489
def has_live_migration_plug_time_event(self):
501490
"""Returns whether this VIF's network-vif-plugged external event will
@@ -564,27 +553,13 @@ def wait(self, do_raise=True):
564553
def json(self):
565554
return jsonutils.dumps(self)
566555

567-
def get_bind_time_events(self, migration):
568-
"""Returns a list of external events for any VIFs that have
569-
"bind-time" events during cold migration.
570-
"""
571-
return [('network-vif-plugged', vif['id'])
572-
for vif in self if vif.has_bind_time_event(migration)]
573-
574556
def get_live_migration_plug_time_events(self):
575557
"""Returns a list of external events for any VIFs that have
576558
"plug-time" events during live migration.
577559
"""
578560
return [('network-vif-plugged', vif['id'])
579561
for vif in self if vif.has_live_migration_plug_time_event]
580562

581-
def get_plug_time_events(self, migration):
582-
"""Returns a list of external events for any VIFs that have
583-
"plug-time" events during cold migration.
584-
"""
585-
return [('network-vif-plugged', vif['id'])
586-
for vif in self if not vif.has_bind_time_event(migration)]
587-
588563
def has_port_with_allocation(self):
589564
return any(vif.has_allocation() for vif in self)
590565

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)