summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVishvananda Ishaya <vishvananda@yahoo.com>2010-10-20 21:29:03 +0000
committerTarmac <>2010-10-20 21:29:03 +0000
commitb07f04b806571f537357e993629b8acd1ea00446 (patch)
tree63d85b9c1a67b38229a5949f5859cfb4ffb0f9d9
parent4de2079303a25a1e6a60d3110788ebb35fcdf37e (diff)
parentd454bff397c29651e20fdea105b3e8cc197d0f5e (diff)
downloadnova-b07f04b806571f537357e993629b8acd1ea00446.tar.gz
nova-b07f04b806571f537357e993629b8acd1ea00446.tar.xz
nova-b07f04b806571f537357e993629b8acd1ea00446.zip
Checks the pid of dnsmasq to make sure it is actually referring to the right process.
-rw-r--r--nova/network/linux_net.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/nova/network/linux_net.py b/nova/network/linux_net.py
index c0be0e8cc..f75a079d9 100644
--- a/nova/network/linux_net.py
+++ b/nova/network/linux_net.py
@@ -167,11 +167,9 @@ def get_dhcp_hosts(context, network_id):
return '\n'.join(hosts)
-# TODO(ja): if the system has restarted or pid numbers have wrapped
-# then you cannot be certain that the pid refers to the
-# dnsmasq. As well, sending a HUP only reloads the hostfile,
-# so any configuration options (like dchp-range, vlan, ...)
-# aren't reloaded
+# NOTE(ja): Sending a HUP only reloads the hostfile, so any
+# configuration options (like dchp-range, vlan, ...)
+# aren't reloaded.
def update_dhcp(context, network_id):
"""(Re)starts a dnsmasq server for a given network
@@ -191,13 +189,15 @@ def update_dhcp(context, network_id):
# if dnsmasq is already running, then tell it to reload
if pid:
- # TODO(ja): use "/proc/%d/cmdline" % (pid) to determine if pid refers
- # correct dnsmasq process
- try:
- _execute('sudo kill -HUP %d' % pid)
- return
- except Exception as exc: # pylint: disable-msg=W0703
- logging.debug("Hupping dnsmasq threw %s", exc)
+ out, _err = _execute('cat /proc/%d/cmdline' % pid, check_exit_code=False)
+ if conffile in out:
+ try:
+ _execute('sudo kill -HUP %d' % pid)
+ return
+ except Exception as exc: # pylint: disable-msg=W0703
+ logging.debug("Hupping dnsmasq threw %s", exc)
+ else:
+ logging.debug("Pid %d is stale, relaunching dnsmasq", pid)
# FLAGFILE and DNSMASQ_INTERFACE in env
env = {'FLAGFILE': FLAGS.dhcpbridge_flagfile,