From cc386fcc242c29cd02fff5f4de3e4a97f93d6bb2 Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Wed, 18 Sep 2024 09:35:22 -0400 Subject: [PATCH] refactor: don't calculate list of attached lbs for every lb Change-Id: Ibb2390a7fba9cfcb1aec48fd339c04e8a1fdafba --- .../plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovn_client.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovn_client.py b/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovn_client.py index f70b70cc031..aadf07a410a 100644 --- a/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovn_client.py +++ b/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovn_client.py @@ -964,10 +964,12 @@ class OVNClient(object): ).execute(check_error=True) all_lswitches = self._nb_idl.db_find_rows( 'Logical_Switch').execute(check_error=True) + attached_lbs = set( + lb for item in all_lswitches for lb in item.load_balancer) commands = [] for lb in lbs: - if not any(lb in item.load_balancer for item in all_lswitches): + if lb not in attached_lbs: # LB is not linked anywhere. continue