]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Stop the dhcp-agent process when dnsmasq version is not determined
authorEdgar Magana <emagana@gmail.com>
Fri, 30 May 2014 23:27:35 +0000 (16:27 -0700)
committerEdgar Magana <emagana@gmail.com>
Mon, 30 Jun 2014 18:57:23 +0000 (11:57 -0700)
When it is not possible to determinate the dnsmasq version
or dnsmasq is not installed, neutron shows only a warning message.
With this commit the dhcp-agent process will be stopped if the
dnsmasq service is not installed.
Modifies the dhcp version unit test with the expected SystemExit exception

Change-Id: Ia26eaae6f432305f412a4b6a4a6b2b7b15d99d45
Closes-Bug: 1212401

neutron/agent/linux/dhcp.py
neutron/tests/unit/test_linux_dhcp.py

index d05cad164262a1ffb36ba58ae778748ee34a0b12..f0b0ec05e90674fe87d2b27ec8d91def9f56ecab 100644 (file)
@@ -318,9 +318,10 @@ class Dnsmasq(DhcpLocalProcess):
                               'Please ensure that its version is %s '
                               'or above!'), cls.MINIMUM_VERSION)
         except (OSError, RuntimeError, IndexError, ValueError):
-            LOG.warning(_('Unable to determine dnsmasq version. '
-                          'Please ensure that its version is %s '
-                          'or above!'), cls.MINIMUM_VERSION)
+            LOG.error(_('Unable to determine dnsmasq version. '
+                        'Please ensure that its version is %s '
+                        'or above!'), cls.MINIMUM_VERSION)
+            raise SystemExit(1)
         return float(ver)
 
     @classmethod
index 9c009e3b4d9ee249c7cc9354580401f8c3cb206c..e3479c5b144d4502bce0145db1fb444c40a20a25 100644 (file)
@@ -18,6 +18,7 @@ import os
 
 import mock
 from oslo.config import cfg
+import testtools
 
 from neutron.agent.common import config
 from neutron.agent.linux import dhcp
@@ -1284,7 +1285,8 @@ tag:tag0,option:router""".lstrip()
                             float(2.48))
 
     def test_check_version_failed_cmd_execution(self):
-        self._check_version('Error while executing command', 0)
+        with testtools.ExpectedException(SystemExit):
+            self._check_version('Error while executing command', 0)
 
     def test_only_populates_dhcp_enabled_subnets(self):
         exp_host_name = '/dhcp/eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee/host'