Merge ~zioproto/ubuntu/+source/neutron:stable/liberty into ~ubuntu-server-dev/ubuntu/+source/neutron:stable/liberty

Proposed by Saverio Proto on 2016-10-27
Status: Needs review
Proposed branch: ~zioproto/ubuntu/+source/neutron:stable/liberty
Merge into: ~ubuntu-server-dev/ubuntu/+source/neutron:stable/liberty
Diff against target: 112 lines (+90/-0)
3 files modified
debian/changelog (+7/-0)
debian/patches/ns-exists-before-get-devices.patch (+82/-0)
debian/patches/series (+1/-0)
Reviewer Review Type Date Requested Status
Corey Bryant 2016-10-27 Pending
Review via email: mp+309457@code.launchpad.net

Description of the Change

To post a comment you must log in.
Corey Bryant (corey.bryant) wrote :

Hi Saverio,

Thanks for the patch.

Do you know how this is fixed, or why it doesn't exist, in Mitaka and above?

I reviewed your latest upstream patch proposal at https://review.openstack.org/#/c/309050/24 and it seemed like a reasonable approach. Can you explain why you've gone with the approach in this merge proposal vs what you had in that upstream review?

Thanks,
Corey

Saverio Proto (zioproto) wrote :

Hello,
I believe the bug is there also in master, but I cannot test it
because I dont have a production environment newer than Liberty. Maybe
you guys at Canonical can help sorting this out ?

The patch I proposed to merge on Ubuntu packages is what I really run
in production and I consider stable.

The patch based in review 309050 patchset 24 improves the previous
patch with a try catch block, to fix a race condition in case the
cronjob is running exactly when the code is running. It is really a
corner case of the corner case, I did not try that patchset in
production.

Both patches are valuable to improve the stability of Neutron.

I would really like the Liberty packages patched with this merge
request, and somebody to help me to make this patch upstream and
backported at least to Newton.

Thanks for your help.

Saverio

2016-10-31 18:06 GMT+01:00 Corey Bryant <email address hidden>:
> Hi Saverio,
>
> Thanks for the patch.
>
> Do you know how this is fixed, or why it doesn't exist, in Mitaka and above?
>
> I reviewed your latest upstream patch proposal at https://review.openstack.org/#/c/309050/24 and it seemed like a reasonable approach. Can you explain why you've gone with the approach in this merge proposal vs what you had in that upstream review?
>
> Thanks,
> Corey
>
>
> --
> https://code.launchpad.net/~zioproto/ubuntu/+source/neutron/+git/neutron/+merge/309457
> You are the owner of ~zioproto/ubuntu/+source/neutron:stable/liberty.

Corey Bryant (corey.bryant) wrote :

Saverio, Can you try to get your latest patches landed upstream in master via https://review.openstack.org/#/c/309050?

Once it lands in master, we can get them backported to upstream stable/newton and stable/mitaka branches. Then we (canonical folks) can help sort the Ubuntu/cloud-archive backports. But we need to get this fixed upstream and on the latest releases before we can fix it in Liberty.

Thanks,
Corey

Saverio Proto (zioproto) wrote :

Hello,
the upstream patch is merged. I just pushed a refreshed commit in my tree, and this merge request got automatically updated.
thank you

Unmerged commits

0986932... by Saverio Proto <email address hidden> on 2016-10-27

Fix router namespace cleanup (LP: #1573073)

* Fix router namespace cleanup (LP: #1573073)
* d/p/ns-exists-before-get-devices.patch

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index fe6d05e..0f2211e 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,10 @@
6+neutron (2:7.2.0-0ubuntu1~cloud0ubuntu1) UNRELEASED; urgency=medium
7+
8+ * Fix router namespace cleanup (LP: #1573073)
9+ * d/p/ns-exists-before-get-devices.patch
10+
11+ -- Saverio Proto <saverio.proto@switch.ch> Thu, 27 Oct 2016 09:33:25 +0000
12+
13 neutron (2:7.2.0-0ubuntu1~cloud0) trusty-liberty; urgency=medium
14
15 * New upstream stable point release for OpenStack Liberty (LP: #1619452).
16diff --git a/debian/patches/ns-exists-before-get-devices.patch b/debian/patches/ns-exists-before-get-devices.patch
17new file mode 100644
18index 0000000..58951ae
19--- /dev/null
20+++ b/debian/patches/ns-exists-before-get-devices.patch
21@@ -0,0 +1,82 @@
22+commit 83c6ace58571f97b4da560c545800eb4d144308b
23+Author: Saverio Proto <saverio.proto@switch.ch>
24+Date: Thu Apr 21 16:50:07 2016 +0200
25+
26+ Check if namespace exists before getting devices
27+
28+ If a neutron router has no ports defined, its namespace is deleted
29+ by the cronjob /etc/cron.d/neutron-l3-agent-netns-cleanup.
30+ It is required to check if the namespace exists before calling
31+ iproute2 commands against the namespace.
32+ It is not enough for the string of the namespace uuid to be defined,
33+ the namespace must really exist on the network node.
34+ This patch checks if the namespace exists when calling get_devices().
35+ Otherwise the agent log file will be flooded with messages like
36+ Cannot open network namespace "qrouter-<uuid>": No such file or directory
37+ Failed to process compatible router '<uuid>'
38+
39+ Related-bug: 1573073
40+
41+ Change-Id: I744ef11529f9da5cbfdb812de0b35b95f9d078bb
42+
43+diff --git a/neutron/agent/linux/ip_lib.py b/neutron/agent/linux/ip_lib.py
44+index 115686f..a4bb9a2 100644
45+--- a/neutron/agent/linux/ip_lib.py
46++++ b/neutron/agent/linux/ip_lib.py
47+@@ -118,12 +118,21 @@ class IPWrapper(SubProcessBase):
48+ # we call out manually because in order to avoid screen scraping
49+ # iproute2 we use find to see what is in the sysfs directory, as
50+ # suggested by Stephen Hemminger (iproute2 dev).
51+- output = utils.execute(['ip', 'netns', 'exec', self.namespace,
52+- 'find', SYS_NET_PATH, '-maxdepth', '1',
53+- '-type', 'l', '-printf', '%f '],
54+- run_as_root=True,
55+- log_fail_as_error=self.log_fail_as_error
56+- ).split()
57++ try:
58++ cmd = ['ip', 'netns', 'exec', self.namespace,
59++ 'find', SYS_NET_PATH, '-maxdepth', '1',
60++ '-type', 'l', '-printf', '%f ']
61++ output = utils.execute(
62++ cmd,
63++ run_as_root=True,
64++ log_fail_as_error=self.log_fail_as_error).split()
65++ except RuntimeError:
66++ # We could be racing with a cron job deleting namespaces.
67++ # Just return a empty list if the namespace is deleted.
68++ with excutils.save_and_reraise_exception() as ctx:
69++ if not self.netns.exists(self.namespace):
70++ ctx.reraise = False
71++ return []
72+ else:
73+ output = (
74+ i for i in os.listdir(SYS_NET_PATH)
75+diff --git a/neutron/tests/unit/agent/linux/test_ip_lib.py b/neutron/tests/unit/agent/linux/test_ip_lib.py
76+index a33f36e..e462962 100644
77+--- a/neutron/tests/unit/agent/linux/test_ip_lib.py
78++++ b/neutron/tests/unit/agent/linux/test_ip_lib.py
79+@@ -281,6 +281,24 @@ class TestIpWrapper(base.BaseTestCase):
80+ self.assertTrue(fake_str.split.called)
81+ self.assertEqual(retval, [ip_lib.IPDevice('lo', namespace='foo')])
82+
83++ @mock.patch('neutron.agent.common.utils.execute')
84++ def test_get_devices_namespaces_ns_not_exists(self, mocked_execute):
85++ mocked_execute.side_effect = RuntimeError(
86++ "Cannot open network namespace")
87++ with mock.patch.object(ip_lib.IpNetnsCommand, 'exists',
88++ return_value=False):
89++ retval = ip_lib.IPWrapper(namespace='foo').get_devices()
90++ self.assertEqual([], retval)
91++
92++ @mock.patch('neutron.agent.common.utils.execute')
93++ def test_get_devices_namespaces_ns_exists(self, mocked_execute):
94++ mocked_execute.side_effect = RuntimeError(
95++ "Cannot open network namespace")
96++ with mock.patch.object(ip_lib.IpNetnsCommand, 'exists',
97++ return_value=True):
98++ self.assertRaises(RuntimeError,
99++ ip_lib.IPWrapper(namespace='foo').get_devices)
100++
101+ def test_get_namespaces(self):
102+ self.execute.return_value = '\n'.join(NETNS_SAMPLE)
103+ retval = ip_lib.IPWrapper.get_namespaces()
104diff --git a/debian/patches/series b/debian/patches/series
105index 2afa859..3ab5e9c 100644
106--- a/debian/patches/series
107+++ b/debian/patches/series
108@@ -2,3 +2,4 @@ fix-test-treat-devices-added-updated-no-local-interface.patch
109 fix-neutron-configuration.patch
110 skip-iptest.patch
111 drop-ryu-dep.patch
112+ns-exists-before-get-devices.patch

Subscribers

People subscribed via source and target branches