From 94271ad8661a36558172d141a84fdd3891786090 Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Mon, 22 Jun 2020 09:47:51 +0000 Subject: [PATCH] [OVS] Make QoS OVS agent deletion operations more resilient When a Port is deleted, the QoS extension will reset any rule (QoS and Queue registers) applied on this port or will reset the related Interface policing parameters. If the Port and the related Interface are deleted during the QoS extension operation, those commands will fail. This patch makes those operations more resiliant by not checking the errors when writing on the Port or the Interface register. NOTE: this patch is squashed with [1]. That will fix the problem with empty "vsctl" transactions when using this OVS DB implementation. [1]https://review.opendev.org/#/c/738574/ Change-Id: I2cc4cdf5be25fab6adbc64acabb3fffebb693fa6 Closes-Bug: #1884512 (cherry picked from commit e2d1c2869a2c8883157d29cf47d7a5236e63dbc1) (cherry picked from commit 84ac8cf9ffb66d826d9d7875bb0d1addc9120034) (cherry picked from commit 3785868bfb387002f4a89d3fa18c20210e8f17db) (cherry picked from commit 7edfb0ef4aba338e0225dffda7c8bf0918ef71cb) --- neutron/agent/common/ovs_lib.py | 23 +++++++++---------- .../tests/unit/agent/common/test_ovs_lib.py | 3 ++- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/neutron/agent/common/ovs_lib.py b/neutron/agent/common/ovs_lib.py index 0a50c8fde07..e06c27c1454 100644 --- a/neutron/agent/common/ovs_lib.py +++ b/neutron/agent/common/ovs_lib.py @@ -703,8 +703,8 @@ class OVSBridge(BaseOVS): self.set_controller_field('inactivity_probe', interval * 1000) def _set_egress_bw_limit_for_port(self, port_name, max_kbps, - max_burst_kbps): - with self.ovsdb.transaction(check_error=True) as txn: + max_burst_kbps, check_error=True): + with self.ovsdb.transaction(check_error=check_error) as txn: txn.add(self.ovsdb.db_set('Interface', port_name, ('ingress_policing_rate', max_kbps))) txn.add(self.ovsdb.db_set('Interface', port_name, @@ -731,8 +731,7 @@ class OVSBridge(BaseOVS): def delete_egress_bw_limit_for_port(self, port_name): if not self.port_exists(port_name): return - self._set_egress_bw_limit_for_port( - port_name, 0, 0) + self._set_egress_bw_limit_for_port(port_name, 0, 0, check_error=False) def find_qos(self, port_name): qos = self.ovsdb.db_find( @@ -903,16 +902,16 @@ class OVSBridge(BaseOVS): return max_kbps, max_burst_kbit def delete_ingress_bw_limit_for_port(self, port_name): + self.ovsdb.db_clear('Port', port_name, + 'qos').execute(check_error=False) qos = self.find_qos(port_name) queue = self.find_queue(port_name, QOS_DEFAULT_QUEUE) - does_port_exist = self.port_exists(port_name) - with self.ovsdb.transaction(check_error=True) as txn: - if does_port_exist: - txn.add(self.ovsdb.db_clear("Port", port_name, 'qos')) - if qos: - txn.add(self.ovsdb.db_destroy('QoS', qos['_uuid'])) - if queue: - txn.add(self.ovsdb.db_destroy('Queue', queue['_uuid'])) + if qos: + self.ovsdb.db_destroy('QoS', + qos['_uuid']).execute(check_error=True) + if queue: + self.ovsdb.db_destroy('Queue', + queue['_uuid']).execute(check_error=True) def set_controller_field(self, field, value): attr = [(field, value)] diff --git a/neutron/tests/unit/agent/common/test_ovs_lib.py b/neutron/tests/unit/agent/common/test_ovs_lib.py index 8736745f0a2..90f0091feaf 100644 --- a/neutron/tests/unit/agent/common/test_ovs_lib.py +++ b/neutron/tests/unit/agent/common/test_ovs_lib.py @@ -844,7 +844,8 @@ class OVS_Lib_Test(base.BaseTestCase): ) as port_exists_mock: self.br.delete_egress_bw_limit_for_port("test_port") port_exists_mock.assert_called_once_with("test_port") - set_egress_mock.assert_called_once_with("test_port", 0, 0) + set_egress_mock.assert_called_once_with("test_port", 0, 0, + check_error=False) def test_delete_egress_bw_limit_for_port_port_not_exists(self): with mock.patch.object(