summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-06-17 10:11:21 +0000
committerGerrit Code Review <review@openstack.org>2017-06-17 10:11:21 +0000
commit0363b21eff13114e51023458550ed2b45de1dfa8 (patch)
treeb77d3a8ca386449b05604229bf3f0a1b37405609
parent9615febab13079048d553c8e931e419ab28318f3 (diff)
parent7ff7ca21bbeea9028bd8582386d536bee62cf6f0 (diff)
Merge "Stop arping when interface gets deleted" into stable/newton
-rw-r--r--neutron/agent/linux/ip_lib.py10
-rw-r--r--neutron/tests/unit/agent/linux/test_ip_lib.py22
2 files changed, 31 insertions, 1 deletions
diff --git a/neutron/agent/linux/ip_lib.py b/neutron/agent/linux/ip_lib.py
index 1849f79..c199596 100644
--- a/neutron/agent/linux/ip_lib.py
+++ b/neutron/agent/linux/ip_lib.py
@@ -1069,15 +1069,23 @@ def _arping(ns_name, iface_name, address, count, log_exception):
1069 # platforms (>=Ubuntu 14.04), arping exit code can be 1. 1069 # platforms (>=Ubuntu 14.04), arping exit code can be 1.
1070 ip_wrapper.netns.execute(arping_cmd, extra_ok_codes=[1]) 1070 ip_wrapper.netns.execute(arping_cmd, extra_ok_codes=[1])
1071 except Exception as exc: 1071 except Exception as exc:
1072 # Since this is spawned in a thread and executed 2 seconds
1073 # apart, the interface may have been deleted while we were
1074 # sleeping. Downgrade message to a warning and return early.
1075 exists = device_exists(iface_name, namespace=ns_name)
1072 msg = _("Failed sending gratuitous ARP to %(addr)s on " 1076 msg = _("Failed sending gratuitous ARP to %(addr)s on "
1073 "%(iface)s in namespace %(ns)s: %(err)s") 1077 "%(iface)s in namespace %(ns)s: %(err)s")
1074 logger_method = LOG.exception 1078 logger_method = LOG.exception
1075 if not log_exception: 1079 if not (log_exception or exists):
1076 logger_method = LOG.warning 1080 logger_method = LOG.warning
1077 logger_method(msg, {'addr': address, 1081 logger_method(msg, {'addr': address,
1078 'iface': iface_name, 1082 'iface': iface_name,
1079 'ns': ns_name, 1083 'ns': ns_name,
1080 'err': exc}) 1084 'err': exc})
1085 if not exists:
1086 LOG.warning(_LW("Interface %s might have been deleted "
1087 "concurrently"), iface_name)
1088 return
1081 1089
1082 1090
1083def send_ip_addr_adv_notif( 1091def send_ip_addr_adv_notif(
diff --git a/neutron/tests/unit/agent/linux/test_ip_lib.py b/neutron/tests/unit/agent/linux/test_ip_lib.py
index 2a92077..f6d3e02 100644
--- a/neutron/tests/unit/agent/linux/test_ip_lib.py
+++ b/neutron/tests/unit/agent/linux/test_ip_lib.py
@@ -1416,6 +1416,28 @@ class TestArpPing(TestIPCmdBase):
1416 ip_wrapper.netns.execute.assert_any_call(arping_cmd, 1416 ip_wrapper.netns.execute.assert_any_call(arping_cmd,
1417 extra_ok_codes=[1]) 1417 extra_ok_codes=[1])
1418 1418
1419 @mock.patch.object(ip_lib, 'IPWrapper')
1420 @mock.patch('eventlet.spawn_n')
1421 def test_send_ipv4_addr_adv_notif_nodev(self, spawn_n, mIPWrapper):
1422 spawn_n.side_effect = lambda f: f()
1423 ip_wrapper = mIPWrapper(namespace=mock.sentinel.ns_name)
1424 ip_wrapper.netns.execute.side_effect = RuntimeError
1425 ARPING_COUNT = 3
1426 address = '20.0.0.1'
1427 config = mock.Mock()
1428 config.send_arp_for_ha = ARPING_COUNT
1429 with mock.patch.object(ip_lib, 'device_exists', return_value=False):
1430 ip_lib.send_ip_addr_adv_notif(mock.sentinel.ns_name,
1431 mock.sentinel.iface_name,
1432 address,
1433 config)
1434
1435 # should return early with a single call when ENODEV
1436 mIPWrapper.assert_has_calls([
1437 mock.call(namespace=mock.sentinel.ns_name),
1438 mock.call().netns.execute(mock.ANY, extra_ok_codes=mock.ANY)
1439 ] * 1)
1440
1419 @mock.patch('eventlet.spawn_n') 1441 @mock.patch('eventlet.spawn_n')
1420 def test_no_ipv6_addr_notif(self, spawn_n): 1442 def test_no_ipv6_addr_notif(self, spawn_n):
1421 ipv6_addr = 'fd00::1' 1443 ipv6_addr = 'fd00::1'