summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-04-26 18:39:13 +0000
committerGerrit Code Review <review@openstack.org>2012-04-26 18:39:13 +0000
commitffde6f92635ea7a9fd3e4bc3ba793c5de07b8a8e (patch)
treeb0f3cd14ae34fcb2ca685fcd93e334b7d6c47777
parenta564f67ee7804838ea3999bb31ad31c37e7991ba (diff)
parent72d0299d438b9bb25fba3fe4a2f5ade8544055ae (diff)
Merge "Introduced _atomic_restart_dhcp() Fixes Bug 977875"
-rw-r--r--nova/network/quantum/manager.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/nova/network/quantum/manager.py b/nova/network/quantum/manager.py
index 1dbcaafe5..3ffc32ddc 100644
--- a/nova/network/quantum/manager.py
+++ b/nova/network/quantum/manager.py
@@ -625,6 +625,19 @@ class QuantumManager(manager.FloatingIP, manager.FlatManager):
LOG.exception(msg)
return ipam_tenant_id
+ # enable_dhcp() could also use this
+ #
+ # Use semaphore to :
+ # 1) avoid race between restart_dhcps
+ # 2) avoid race between update_dhcp_hostfile_with_texts
+ @utils.synchronized('quantum-restart-dhcp')
+ def _atomic_restart_dhcp(self, context, dev, hosts, network_ref):
+ self.driver.update_dhcp_hostfile_with_text(dev, hosts)
+ # Since we only update hosts file, explict kill_dhcp() isn't needed.
+ # restart_dhcp() will reload hostfile if dnsmasq is already running,
+ # or start new dnsmasq
+ self.driver.restart_dhcp(context, dev, network_ref)
+
# TODO(bgh): At some point we should consider merging enable_dhcp() and
# update_dhcp()
# TODO(tr3buchet): agree, i'm curious why they differ even now..
@@ -650,10 +663,8 @@ class QuantumManager(manager.FloatingIP, manager.FlatManager):
# And remove the dhcp mappings for the subnet
hosts = self.get_dhcp_hosts_text(context,
subnet['network_id'], project_id)
- self.driver.update_dhcp_hostfile_with_text(dev, hosts)
- # Restart dnsmasq
- self.driver.kill_dhcp(dev)
- self.driver.restart_dhcp(context, dev, network_ref)
+
+ self._atomic_restart_dhcp(context, dev, hosts, network_ref)
def validate_networks(self, context, networks):
"""Validates that this tenant has quantum networks with the associated