Fixed nova-network dhcp-hostsfile update during live-migration

During live migration _post_live_migration and
post_live_migration_at_destination_method are executed
simultaneously, because second one is called over rpc.cast
In _post_live_migration method there was setup_network_on_host
call with teardown=True, which expects new host in instances
table db field. This update could be happened later, as it
executes on destination node in second method. To guarantee
execution order  setup_network_on_host call, which cleans
dhcp-hostfile is moved to destination node.
Closes-Bug: #1444497

Change-Id: I55f0c0148c937601e78f0beecc21b30a1164a690
This commit is contained in:
Timofey Durakov 2015-04-15 17:29:00 +03:00
parent feef80c1f8
commit d15c57a499
2 changed files with 6 additions and 11 deletions

View File

@ -5350,9 +5350,6 @@ class ComputeManager(manager.Manager):
migrate_data=migrate_data,
destroy_vifs=destroy_vifs)
# NOTE(tr3buchet): tear down networks on source host
self.network_api.setup_networks_on_host(ctxt, instance,
self.host, teardown=True)
self.instance_events.clear_events_for_instance(instance)
# NOTE(timello): make sure we update available resources on source
@ -5418,6 +5415,7 @@ class ComputeManager(manager.Manager):
# Restore instance state
current_power_state = self._get_power_state(context, instance)
node_name = None
prev_host = instance.host
try:
compute_node = self._get_compute_info(context, self.host)
node_name = compute_node.hypervisor_hostname
@ -5430,6 +5428,9 @@ class ComputeManager(manager.Manager):
instance.node = node_name
instance.save(expected_task_state=task_states.MIGRATING)
# NOTE(tr3buchet): tear down networks on source host
self.network_api.setup_networks_on_host(context, instance,
prev_host, teardown=True)
# NOTE(vish): this is necessary to update dhcp
self.network_api.setup_networks_on_host(context, instance, self.host)
self._notify_about_instance_usage(

View File

@ -5563,9 +5563,6 @@ class ComputeTestCase(BaseTestCase):
self.mox.StubOutWithMock(self.compute.network_api,
'setup_networks_on_host')
self.compute.network_api.setup_networks_on_host(c, instance,
instance['host'],
teardown=True)
self.mox.StubOutWithMock(self.compute.instance_events,
'clear_events_for_instance')
self.compute.instance_events.clear_events_for_instance(
@ -5625,9 +5622,6 @@ class ComputeTestCase(BaseTestCase):
self.mox.StubOutWithMock(self.compute.network_api,
'setup_networks_on_host')
self.compute.network_api.setup_networks_on_host(c, instance,
self.compute.host,
teardown=True)
self.mox.StubOutWithMock(self.compute.instance_events,
'clear_events_for_instance')
self.compute.instance_events.clear_events_for_instance(
@ -5694,8 +5688,6 @@ class ComputeTestCase(BaseTestCase):
mock.call(c, instance, False, dest)])
post_live_migration_at_source.assert_has_calls(
[mock.call(c, instance, [])])
setup_networks_on_host.assert_has_calls([
mock.call(c, instance, self.compute.host, teardown=True)])
clear_events.assert_called_once_with(instance)
update_available_resource.assert_has_calls([mock.call(c)])
@ -5780,6 +5772,8 @@ class ComputeTestCase(BaseTestCase):
self.instance).AndReturn(10001)
def _finish_post_live_migration_at_destination(self):
self.compute.network_api.setup_networks_on_host(self.admin_ctxt,
mox.IgnoreArg(), mox.IgnoreArg(), teardown=True)
self.compute.network_api.setup_networks_on_host(self.admin_ctxt,
mox.IgnoreArg(), self.compute.host)