diff options
| author | Mandar Vaze <mandar.vaze@vertex.co.in> | 2012-04-12 05:45:24 -0700 |
|---|---|---|
| committer | Mandar Vaze <mandar.vaze@vertex.co.in> | 2012-04-25 22:44:44 -0700 |
| commit | 72d0299d438b9bb25fba3fe4a2f5ade8544055ae (patch) | |
| tree | 2737b96199aa11d5ec3658ce0c9f85bb3f9c9de8 | |
| parent | caa1b282c701d5e9b9e02ffdb07d432d9b35ed13 (diff) | |
Introduced _atomic_restart_dhcp() Fixes Bug 977875
Introduced a new method which executes update_dhcp_text_file
and restart_dhcp as one atomic unit - to avoid race between these
steps.
Change-Id: I6fda9fbfcaf59fa6a4859b361574d98e16331882
| -rw-r--r-- | nova/network/quantum/manager.py | 19 |
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 |
