summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-06-17 10:11:36 +0000
committerGerrit Code Review <review@openstack.org>2017-06-17 10:11:36 +0000
commit9220204ffbeddd5c3a0cd42c7e62dd10c3909c86 (patch)
treea06dea3838f17953f4465901b4b9fc44ffff5f0f
parent27f2f8e44f10bde0968cde96cc5ce443408ef120 (diff)
parentbe13101ec4ad521556ec890aafa462244de50f7d (diff)
Merge "Stop arping when interface gets deleted" into stable/ocata
-rw-r--r--neutron/agent/linux/ip_lib.py10
-rw-r--r--neutron/tests/unit/agent/linux/test_ip_lib.py20
2 files changed, 29 insertions, 1 deletions
diff --git a/neutron/agent/linux/ip_lib.py b/neutron/agent/linux/ip_lib.py
index f517c6b..278e3da 100644
--- a/neutron/agent/linux/ip_lib.py
+++ b/neutron/agent/linux/ip_lib.py
@@ -1077,15 +1077,23 @@ def _arping(ns_name, iface_name, address, count, log_exception):
1077 # platforms (>=Ubuntu 14.04), arping exit code can be 1. 1077 # platforms (>=Ubuntu 14.04), arping exit code can be 1.
1078 ip_wrapper.netns.execute(arping_cmd, extra_ok_codes=[1]) 1078 ip_wrapper.netns.execute(arping_cmd, extra_ok_codes=[1])
1079 except Exception as exc: 1079 except Exception as exc:
1080 # Since this is spawned in a thread and executed 2 seconds
1081 # apart, the interface may have been deleted while we were
1082 # sleeping. Downgrade message to a warning and return early.
1083 exists = device_exists(iface_name, namespace=ns_name)
1080 msg = _("Failed sending gratuitous ARP to %(addr)s on " 1084 msg = _("Failed sending gratuitous ARP to %(addr)s on "
1081 "%(iface)s in namespace %(ns)s: %(err)s") 1085 "%(iface)s in namespace %(ns)s: %(err)s")
1082 logger_method = LOG.exception 1086 logger_method = LOG.exception
1083 if not log_exception: 1087 if not (log_exception or exists):
1084 logger_method = LOG.warning 1088 logger_method = LOG.warning
1085 logger_method(msg, {'addr': address, 1089 logger_method(msg, {'addr': address,
1086 'iface': iface_name, 1090 'iface': iface_name,
1087 'ns': ns_name, 1091 'ns': ns_name,
1088 'err': exc}) 1092 'err': exc})
1093 if not exists:
1094 LOG.warning(_LW("Interface %s might have been deleted "
1095 "concurrently"), iface_name)
1096 return
1089 1097
1090 1098
1091def send_ip_addr_adv_notif( 1099def 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 d1e1936..bf4626d 100644
--- a/neutron/tests/unit/agent/linux/test_ip_lib.py
+++ b/neutron/tests/unit/agent/linux/test_ip_lib.py
@@ -1683,6 +1683,26 @@ class TestArpPing(TestIPCmdBase):
1683 ip_wrapper.netns.execute.assert_any_call(arping_cmd, 1683 ip_wrapper.netns.execute.assert_any_call(arping_cmd,
1684 extra_ok_codes=[1]) 1684 extra_ok_codes=[1])
1685 1685
1686 @mock.patch.object(ip_lib, 'IPWrapper')
1687 @mock.patch('eventlet.spawn_n')
1688 def test_send_ipv4_addr_adv_notif_nodev(self, spawn_n, mIPWrapper):
1689 spawn_n.side_effect = lambda f: f()
1690 ip_wrapper = mIPWrapper(namespace=mock.sentinel.ns_name)
1691 ip_wrapper.netns.execute.side_effect = RuntimeError
1692 ARPING_COUNT = 3
1693 address = '20.0.0.1'
1694 with mock.patch.object(ip_lib, 'device_exists', return_value=False):
1695 ip_lib.send_ip_addr_adv_notif(mock.sentinel.ns_name,
1696 mock.sentinel.iface_name,
1697 address,
1698 ARPING_COUNT)
1699
1700 # should return early with a single call when ENODEV
1701 mIPWrapper.assert_has_calls([
1702 mock.call(namespace=mock.sentinel.ns_name),
1703 mock.call().netns.execute(mock.ANY, extra_ok_codes=mock.ANY)
1704 ] * 1)
1705
1686 @mock.patch('eventlet.spawn_n') 1706 @mock.patch('eventlet.spawn_n')
1687 def test_no_ipv6_addr_notif(self, spawn_n): 1707 def test_no_ipv6_addr_notif(self, spawn_n):
1688 ipv6_addr = 'fd00::1' 1708 ipv6_addr = 'fd00::1'