]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Ignore non-existent ports during OVS intf list
authorKevin Benton <blak111@gmail.com>
Sun, 4 Jan 2015 09:47:01 +0000 (01:47 -0800)
committerKevin Benton <kevinbenton@buttewifi.com>
Sun, 4 Jan 2015 12:16:42 +0000 (12:16 +0000)
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
neutron/tests/unit/agent/linux/test_ovs_lib.py

index 1c712fd7a69ffa05265daa52d589f227184e533a..7b2d2a22531867128a212ffb627135d338b83659 100644 (file)
@@ -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 = {}
index a43e38ce614c725be2d979899b4a71d965a2d755..4112f38efd0e6ecc2d661722cb62cadcac84c08e 100644 (file)
@@ -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()),