From 5de1d2ed67e00a010f23c5f9055556745a55957a Mon Sep 17 00:00:00 2001 From: Kevin Benton Date: Sun, 4 Jan 2015 01:47:01 -0800 Subject: [PATCH] Ignore non-existent ports during OVS intf list A recent commit[1] to pass the list of port names directly to ovs-vsctl during a list operation introduced a new possible failure condition where one of the names might refer to a port which no longer exists. By default this causes ovs-vsctl to quit in a fit of rage[2]. Previously, all interfaces were retrieved and the ones that were a subset of the name list were processed. The name list could contain extra non-existent names (e.g. recently deleted interfaces). This patch just passes the '--if-exists' flag to the 'list Interface' command to match the same previous behavior. 1. 3f0bf6cfac2e151d5a4a7f076062b3365bdbf457 2. Example: Stderr: 'ovs-vsctl: no row "tap80664420-ea" in table Interface\n' Closes-Bug: #1407190 Change-Id: I8f359981386d13fb455281a72b8bb245395c0909 --- neutron/agent/linux/ovs_lib.py | 6 ++++-- neutron/tests/unit/agent/linux/test_ovs_lib.py | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/neutron/agent/linux/ovs_lib.py b/neutron/agent/linux/ovs_lib.py index 1c712fd7a69..7b2d2a22531 100644 --- a/neutron/agent/linux/ovs_lib.py +++ b/neutron/agent/linux/ovs_lib.py @@ -363,7 +363,8 @@ class OVSBridge(BaseOVS): def get_vif_port_set(self): edge_ports = set() args = ['--format=json', '--', '--columns=external_ids,ofport', - 'list', 'Interface'] + self.get_port_name_list() + '--if-exists', 'list', 'Interface'] + args += self.get_port_name_list() result = self.run_vsctl(args, check_error=True) if not result: return edge_ports @@ -404,7 +405,8 @@ class OVSBridge(BaseOVS): in the "Interface" table queried by the get_vif_port_set() method. """ - args = ['--format=json', '--', '--columns=name,tag', 'list', 'Port'] + args = ['--format=json', '--', '--columns=name,tag', '--if-exists', + 'list', 'Port'] args += self.get_port_name_list() result = self.run_vsctl(args, check_error=True) port_tag_dict = {} diff --git a/neutron/tests/unit/agent/linux/test_ovs_lib.py b/neutron/tests/unit/agent/linux/test_ovs_lib.py index a43e38ce614..4112f38efd0 100644 --- a/neutron/tests/unit/agent/linux/test_ovs_lib.py +++ b/neutron/tests/unit/agent/linux/test_ovs_lib.py @@ -655,7 +655,7 @@ class OVS_Lib_Test(base.BaseTestCase): root_helper=self.root_helper), 'tap99\ntun22'), (mock.call(["ovs-vsctl", self.TO, "--format=json", - "--", "--columns=external_ids,ofport", + "--", "--columns=external_ids,ofport", '--if-exists', "list", "Interface", 'tap99', 'tun22'], root_helper=self.root_helper), self._encode_ovs_json(headings, data)), @@ -711,7 +711,7 @@ class OVS_Lib_Test(base.BaseTestCase): root_helper=self.root_helper), 'tap99\n'), (mock.call(["ovs-vsctl", self.TO, "--format=json", - "--", "--columns=external_ids,ofport", + "--", "--columns=external_ids,ofport", '--if-exists', "list", "Interface", "tap99"], root_helper=self.root_helper), RuntimeError()),