From: Terry Wilson Date: Tue, 24 Feb 2015 01:31:02 +0000 (-0600) Subject: Ensure arping always exits X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=c308dc89076e99d15cac7100ecc90df2ddb5f4fa;p=openstack-build%2Fneutron-build.git Ensure arping always exits 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 --- diff --git a/neutron/agent/linux/ip_lib.py b/neutron/agent/linux/ip_lib.py index f503134f2..29e5a4f10 100644 --- a/neutron/agent/linux/ip_lib.py +++ b/neutron/agent/linux/ip_lib.py @@ -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) diff --git a/neutron/tests/unit/test_linux_ip_lib.py b/neutron/tests/unit/test_linux_ip_lib.py index 589f091db..2fdfd1ada 100644 --- a/neutron/tests/unit/test_linux_ip_lib.py +++ b/neutron/tests/unit/test_linux_ip_lib.py @@ -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)