From 20fa3f267ebe7e2feb60d930af4a58a77cb9334c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C5=82awek=20Kap=C5=82o=C5=84ski?= Date: Fri, 12 Jan 2018 23:08:56 +0100 Subject: [PATCH] [OVS] Fix for cleaning after skipped_devices When Openvswitch agent will get "port_update" event (e.g. to set port as unbound) and port is already removed from br-int when agent tries to get vif port in treat_devices_added_updated() method (port is removed because e.g. nova-compute removes it) then resources set for port by L2 agent extension drivers (like qos) are not cleaned properly. In such case port is added to skipped_ports and is set as DOWN in neutron-db but ext_manager is not called then for such port so it will not clear stuff like bandwidth limit's QoS and queue records and also DSCP marking open flow rules for this port. This patch fixes this issue by adding call of ext_manager.delete_port() method for all skipped ports. Change-Id: I3cf5c57c7f232deaa190ab6b0129e398fdabe592 Closes-Bug: #1737892 (cherry picked from commit a8271e978a1c540ae9888f568cf14b4c40ea1b6d) (cherry picked from commit cdcc704b9e0c6eb3eb8500e5791b007e85653c13) --- .../ml2/drivers/openvswitch/agent/ovs_neutron_agent.py | 1 + .../ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py b/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py index 26863c7a195..a72f46802a5 100644 --- a/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py +++ b/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py @@ -1507,6 +1507,7 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin, # The port disappeared and cannot be processed LOG.info(_LI("Port %s was not found on the integration bridge " "and will therefore not be processed"), device) + self.ext_manager.delete_port(self.context, {'port_id': device}) skipped_devices.append(device) continue diff --git a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py index a2950454b20..12f7a5c752a 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py +++ b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py @@ -843,12 +843,16 @@ class TestOvsNeutronAgent(object): mock.patch.object(self.agent.int_br, 'get_vifs_by_ids', return_value={}),\ + mock.patch.object(self.agent.ext_manager, + "delete_port") as ext_mgr_delete_port,\ mock.patch.object(self.agent, 'treat_vif_port') as treat_vif_port: skip_devs = self.agent.treat_devices_added_or_updated([], False) # The function should return False for resync and no device # processed self.assertEqual((['the_skipped_one'], [], set()), skip_devs) + ext_mgr_delete_port.assert_called_once_with( + self.agent.context, {'port_id': 'the_skipped_one'}) self.assertFalse(treat_vif_port.called) def test_treat_devices_added_failed_devices(self):