]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Ensure arping always exits
authorTerry Wilson <twilson@redhat.com>
Tue, 24 Feb 2015 01:31:02 +0000 (19:31 -0600)
committerTerry Wilson <twilson@redhat.com>
Tue, 24 Feb 2015 18:08:51 +0000 (12:08 -0600)
It is possible for the arping process to hang if the interface is
removed while it is running. This patch adds a timeout to ensure
that the process eventually exits no matter what.

Change-Id: I60458b91e88b3fbd9fbc19c004e47a005b0ed408
Closes-Bug: #1425173

neutron/agent/linux/ip_lib.py
neutron/tests/unit/test_linux_ip_lib.py

index f503134f2ce37b90c29f070467a2a4d351855c8f..29e5a4f109e5b54e7a2a2e9ebc32b54b705940cf 100644 (file)
@@ -643,7 +643,9 @@ def iproute_arg_supported(command, arg):
 
 
 def _arping(ns_name, iface_name, address, count):
-    arping_cmd = ['arping', '-A', '-I', iface_name, '-c', count, address]
+    # Pass -w to set timeout to ensure exit if interface removed while running
+    arping_cmd = ['arping', '-A', '-I', iface_name, '-c', count,
+                  '-w', 1.5 * count, address]
     try:
         ip_wrapper = IPWrapper(namespace=ns_name)
         ip_wrapper.netns.execute(arping_cmd, check_exit_code=True)
index 589f091db56655e30117a95710485f3975305335..2fdfd1adac016b23452d1b379a2a62581150a974 100644 (file)
@@ -945,10 +945,11 @@ class TestIpNeighCommand(TestIPCmdBase):
 class TestArpPing(TestIPCmdBase):
     def _test_arping(self, function, address, spawn_n, mIPWrapper):
         spawn_n.side_effect = lambda f: f()
+        ARPING_COUNT = 3
         function(mock.sentinel.ns_name,
                  mock.sentinel.iface_name,
                  address,
-                 mock.sentinel.count)
+                 ARPING_COUNT)
 
         self.assertTrue(spawn_n.called)
         mIPWrapper.assert_called_once_with(namespace=mock.sentinel.ns_name)
@@ -958,7 +959,8 @@ class TestArpPing(TestIPCmdBase):
         # Just test that arping is called with the right arguments
         arping_cmd = ['arping', '-A',
                       '-I', mock.sentinel.iface_name,
-                      '-c', mock.sentinel.count,
+                      '-c', ARPING_COUNT,
+                      '-w', mock.ANY,
                       address]
         ip_wrapper.netns.execute.assert_any_call(arping_cmd,
                                                  check_exit_code=True)