From ea999564a5b80dcf13c0c43f107165f0754210b7 Mon Sep 17 00:00:00 2001 From: Lucas Alvares Gomes Date: Fri, 27 Mar 2020 15:23:49 +0000 Subject: [PATCH] [OVN] HA Chassis Group: Ignore UPDATES when external_ids hasn't changed The "old" parameter passed to the handle_ha_chassis_group_changes() method is a delta object and sometimes it does not contain the "external_ids" column (because it hasn't changed). The absence of that column was misleading that method into believe that the "old" object was no longer a gateway chassis and that triggered some changes in the HA group. Changing the HA group resulted in the SRIOV (external in OVN) ports to start flapping between the gateway chassis. This patch is adding a check to verify that the "external_ids" column has changed before acting on it, otherwise just ignore the update and return. Closes-Bug: #1869389 Change-Id: I3f7de633e5546dc78c3546b9c34ea81d0a0524d3 Signed-off-by: Lucas Alvares Gomes --- .../ml2/drivers/ovn/mech_driver/ovsdb/ovsdb_monitor.py | 5 +++++ .../drivers/ovn/mech_driver/ovsdb/test_ovsdb_monitor.py | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovsdb_monitor.py b/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovsdb_monitor.py index 8628847d52a..d43973e134d 100644 --- a/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovsdb_monitor.py +++ b/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovsdb_monitor.py @@ -82,6 +82,11 @@ class ChassisEvent(row_event.RowEvent): if not self.driver._ovn_client.is_external_ports_supported(): return + # NOTE(lucasgomes): If the external_ids column wasn't updated + # (meaning, Chassis "gateway" status didn't change) just returns + if not hasattr(old, 'external_ids') and event == self.ROW_UPDATE: + return + is_gw_chassis = utils.is_gateway_chassis(row) # If the Chassis being created is not a gateway, ignore it if not is_gw_chassis and event == self.ROW_CREATE: diff --git a/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_ovsdb_monitor.py b/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_ovsdb_monitor.py index ac5ad29a8c1..3d21d458cec 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_ovsdb_monitor.py +++ b/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_ovsdb_monitor.py @@ -558,3 +558,12 @@ class TestChassisEvent(base.BaseTestCase): # after it became a Gateway chassis self._test_handle_ha_chassis_group_changes_create( self.event.ROW_UPDATE) + + def test_handle_ha_chassis_group_changes_update_ext_id_not_found(self): + self.is_gw_ch_mock.side_effect = (True, False) + old = fakes.FakeOvsdbTable.create_one_ovsdb_table( + attrs={'name': 'SpongeBob'}) + self.assertIsNone(self.event.handle_ha_chassis_group_changes( + self.event.ROW_UPDATE, mock.Mock(), old)) + self.assertFalse(self.nb_ovn.ha_chassis_group_add_chassis.called) + self.assertFalse(self.nb_ovn.ha_chassis_group_del_chassis.called)