Skip to content

Commit e9c60dc

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "only wait for plugtime events in pre-live-migration" into stable/victoria
2 parents 2e31f6a + ef348c4 commit e9c60dc

File tree

3 files changed

+48
-11
lines changed

3 files changed

+48
-11
lines changed

nova/compute/manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8075,8 +8075,8 @@ def _get_neutron_events_for_live_migration(instance):
80758075
# We don't generate events if CONF.vif_plugging_timeout=0
80768076
# meaning that the operator disabled using them.
80778077
if CONF.vif_plugging_timeout:
8078-
return [('network-vif-plugged', vif['id'])
8079-
for vif in instance.get_network_info()]
8078+
return (instance.get_network_info()
8079+
.get_live_migration_plug_time_events())
80808080
else:
80818081
return []
80828082

nova/network/model.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,14 @@ def has_bind_time_event(self, migration):
469469
return (self.is_hybrid_plug_enabled() and not
470470
migration.is_same_host())
471471

472+
@property
473+
def has_live_migration_plug_time_event(self):
474+
"""Returns whether this VIF's network-vif-plugged external event will
475+
be sent by Neutron at "plugtime" - in other words, as soon as neutron
476+
completes configuring the network backend.
477+
"""
478+
return self.is_hybrid_plug_enabled()
479+
472480
def is_hybrid_plug_enabled(self):
473481
return self['details'].get(VIF_DETAILS_OVS_HYBRID_PLUG, False)
474482

@@ -530,15 +538,22 @@ def json(self):
530538
return jsonutils.dumps(self)
531539

532540
def get_bind_time_events(self, migration):
533-
"""Returns whether any of our VIFs have "bind-time" events. See
534-
has_bind_time_event() docstring for more details.
541+
"""Returns a list of external events for any VIFs that have
542+
"bind-time" events during cold migration.
535543
"""
536544
return [('network-vif-plugged', vif['id'])
537545
for vif in self if vif.has_bind_time_event(migration)]
538546

547+
def get_live_migration_plug_time_events(self):
548+
"""Returns a list of external events for any VIFs that have
549+
"plug-time" events during live migration.
550+
"""
551+
return [('network-vif-plugged', vif['id'])
552+
for vif in self if vif.has_live_migration_plug_time_event]
553+
539554
def get_plug_time_events(self, migration):
540-
"""Complementary to get_bind_time_events(), any event that does not
541-
fall in that category is a plug-time event.
555+
"""Returns a list of external events for any VIFs that have
556+
"plug-time" events during cold migration.
542557
"""
543558
return [('network-vif-plugged', vif['id'])
544559
for vif in self if not vif.has_bind_time_event(migration)]

nova/tests/unit/compute/test_compute_mgr.py

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9316,12 +9316,18 @@ def test_get_neutron_events_for_live_migration_empty(self):
93169316
"""Tests the various ways that _get_neutron_events_for_live_migration
93179317
will return an empty list.
93189318
"""
9319+
migration = mock.Mock()
9320+
migration.is_same_host = lambda: False
9321+
self.assertFalse(migration.is_same_host())
9322+
93199323
# 1. no timeout
93209324
self.flags(vif_plugging_timeout=0)
93219325

93229326
with mock.patch.object(self.instance, 'get_network_info') as nw_info:
93239327
nw_info.return_value = network_model.NetworkInfo(
9324-
[network_model.VIF(uuids.port1)])
9328+
[network_model.VIF(uuids.port1, details={
9329+
network_model.VIF_DETAILS_OVS_HYBRID_PLUG: True})])
9330+
self.assertTrue(nw_info.return_value[0].is_hybrid_plug_enabled())
93259331
self.assertEqual(
93269332
[], self.compute._get_neutron_events_for_live_migration(
93279333
self.instance))
@@ -9330,7 +9336,18 @@ def test_get_neutron_events_for_live_migration_empty(self):
93309336
self.flags(vif_plugging_timeout=300)
93319337

93329338
with mock.patch.object(self.instance, 'get_network_info') as nw_info:
9333-
nw_info.return_value = []
9339+
nw_info.return_value = network_model.NetworkInfo([])
9340+
self.assertEqual(
9341+
[], self.compute._get_neutron_events_for_live_migration(
9342+
self.instance))
9343+
9344+
# 3. no plug time events
9345+
with mock.patch.object(self.instance, 'get_network_info') as nw_info:
9346+
nw_info.return_value = network_model.NetworkInfo(
9347+
[network_model.VIF(
9348+
uuids.port1, details={
9349+
network_model.VIF_DETAILS_OVS_HYBRID_PLUG: False})])
9350+
self.assertFalse(nw_info.return_value[0].is_hybrid_plug_enabled())
93349351
self.assertEqual(
93359352
[], self.compute._get_neutron_events_for_live_migration(
93369353
self.instance))
@@ -9348,9 +9365,11 @@ def test_live_migration_wait_vif_plugged(
93489365
wait_for_vif_plugged=True)
93499366
mock_get_bdms.return_value = objects.BlockDeviceMappingList(objects=[])
93509367
mock_pre_live_mig.return_value = migrate_data
9368+
details = {network_model.VIF_DETAILS_OVS_HYBRID_PLUG: True}
93519369
self.instance.info_cache = objects.InstanceInfoCache(
93529370
network_info=network_model.NetworkInfo([
9353-
network_model.VIF(uuids.port1), network_model.VIF(uuids.port2)
9371+
network_model.VIF(uuids.port1, details=details),
9372+
network_model.VIF(uuids.port2, details=details)
93549373
]))
93559374
self.compute._waiting_live_migrations[self.instance.uuid] = (
93569375
self.migration, mock.MagicMock()
@@ -9380,11 +9399,12 @@ def test_live_migration_wait_vif_plugged_old_dest_host(
93809399
of not waiting.
93819400
"""
93829401
migrate_data = objects.LibvirtLiveMigrateData()
9402+
details = {network_model.VIF_DETAILS_OVS_HYBRID_PLUG: True}
93839403
mock_get_bdms.return_value = objects.BlockDeviceMappingList(objects=[])
93849404
mock_pre_live_mig.return_value = migrate_data
93859405
self.instance.info_cache = objects.InstanceInfoCache(
93869406
network_info=network_model.NetworkInfo([
9387-
network_model.VIF(uuids.port1)]))
9407+
network_model.VIF(uuids.port1, details=details)]))
93889408
self.compute._waiting_live_migrations[self.instance.uuid] = (
93899409
self.migration, mock.MagicMock()
93909410
)
@@ -9528,9 +9548,11 @@ def test_live_migration_aborted_before_running(self, mock_rpc,
95289548
mock_get_bdms.return_value = source_bdms
95299549
migrate_data = objects.LibvirtLiveMigrateData(
95309550
wait_for_vif_plugged=True)
9551+
details = {network_model.VIF_DETAILS_OVS_HYBRID_PLUG: True}
95319552
self.instance.info_cache = objects.InstanceInfoCache(
95329553
network_info=network_model.NetworkInfo([
9533-
network_model.VIF(uuids.port1), network_model.VIF(uuids.port2)
9554+
network_model.VIF(uuids.port1, details=details),
9555+
network_model.VIF(uuids.port2, details=details)
95349556
]))
95359557
self.compute._waiting_live_migrations = {}
95369558
fake_migration = objects.Migration(

0 commit comments

Comments
 (0)