From 727da57e8145356f3c56175bea3823de3abc1e44 Mon Sep 17 00:00:00 2001 From: "John L. Villalovos" Date: Mon, 6 Feb 2017 14:24:42 -0800 Subject: [PATCH] Fix error in 'ip netns' parsing Sometimes when doing worlddump would see a command line like this: sudo ip netns exec (id: ip addr This would cause an error to be seen in console.log: 2017-02-07 00:03:03.659570 | /bin/sh: 1: Syntax error: "(" unexpected This is caused by there sometimes being extra data returned from the 'ip netns' command [1]. For example it might look like: qrouter-0805fd7d-c493-4fa6-82ca-1c6c9b23cd9e (id: 1) qdhcp-bb2cc6ae-2ae8-474f-adda-a94059b872b5 (id: 0) [1] https://lwn.net/Articles/629715/ Change-Id: Icece442023125ef55696b8d92a975d37e358b1b4 Closes-Bug: 1653969 (cherry picked from commit c6e6939e89a44a408065eb4585963175f8d0d6e3) --- tools/worlddump.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/worlddump.py b/tools/worlddump.py index 1ce931efd5..8b418ede5a 100755 --- a/tools/worlddump.py +++ b/tools/worlddump.py @@ -151,7 +151,11 @@ def iptables_dump(): def _netns_list(): process = subprocess.Popen(['ip', 'netns'], stdout=subprocess.PIPE) stdout, _ = process.communicate() - return stdout.split() + # NOTE(jlvillal): Sometimes 'ip netns list' can return output like: + # qrouter-0805fd7d-c493-4fa6-82ca-1c6c9b23cd9e (id: 1) + # qdhcp-bb2cc6ae-2ae8-474f-adda-a94059b872b5 (id: 0) + output = [x.split()[0] for x in stdout.splitlines()] + return output def network_dump():