From f8e0a497ad6a36fa0d9510cda9e7344c2ed73763 Mon Sep 17 00:00:00 2001 From: Slawek Kaplonski Date: Thu, 17 Jan 2019 18:18:49 +0100 Subject: [PATCH] Skip ovsdb_monitor events for ports with ofport=-1 There is no need to trigger neutron-openvswitch-agent to start processing ports in case if invalid port (with ofport=-1) will be added to bridge. Such port will be processed later when ofport will be changed. Change-Id: I3465daf4809d5d56565f59b177b5f8870352cc9d Related-Bug: #1808171 Related-Bug: #1811405 --- neutron/agent/common/ovsdb_monitor.py | 6 ++++++ neutron/tests/unit/agent/common/test_ovsdb_monitor.py | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/neutron/agent/common/ovsdb_monitor.py b/neutron/agent/common/ovsdb_monitor.py index a6d71665af1..a3a575568d3 100644 --- a/neutron/agent/common/ovsdb_monitor.py +++ b/neutron/agent/common/ovsdb_monitor.py @@ -16,6 +16,7 @@ from oslo_log import log as logging from oslo_serialization import jsonutils from neutron.agent.common import async_process +from neutron.agent.common import ovs_lib from neutron.agent.ovsdb import api as ovsdb from neutron.agent.ovsdb.native import helpers from neutron.common import utils @@ -108,6 +109,11 @@ class SimpleInterfaceMonitor(OvsdbMonitor): external_ids = ovsdb.val_to_py(external_ids) if ofport: ofport = ovsdb.val_to_py(ofport) + if ofport == ovs_lib.INVALID_OFPORT: + LOG.debug("Ofport of port %(name)s is %(ofport)s. " + "Skipping its event.", + {'name': name, 'ofport': ofport}) + continue device = {'name': name, 'ofport': ofport, 'external_ids': external_ids} diff --git a/neutron/tests/unit/agent/common/test_ovsdb_monitor.py b/neutron/tests/unit/agent/common/test_ovsdb_monitor.py index fc645ee61d9..71043b18021 100644 --- a/neutron/tests/unit/agent/common/test_ovsdb_monitor.py +++ b/neutron/tests/unit/agent/common/test_ovsdb_monitor.py @@ -85,3 +85,12 @@ class TestSimpleInterfaceMonitor(base.BaseTestCase): self.monitor.process_events() self.assertEqual(self.monitor.new_events['added'][0]['ofport'], ovs_lib.UNASSIGNED_OFPORT) + + def process_event_invalid_of_port(self): + output = '{"data":[["e040fbec-0579-4990-8324-d338da33ae88","insert",' + output += '"m50",-1,["map",[]]]],"headings":["row","action",' + output += '"name","ofport","external_ids"]}' + with mock.patch.object( + self.monitor, 'iter_stdout', return_value=[output]): + self.monitor.process_events() + self.assertEqual([], self.monitor.new_events['added'])