From e38836707634f4973b62392ced0a0b0f533824c2 Mon Sep 17 00:00:00 2001 From: Luis Tomas Bolivar Date: Thu, 14 Dec 2023 13:01:28 +0100 Subject: [PATCH] Fix watcher logic for exposing OVN LB with the NB DB driver Change-Id: I0641e79139d2452f1d6053f878769ff18a4a8a7d --- ovn_bgp_agent/drivers/openstack/watchers/nb_bgp_watcher.py | 5 ++--- .../unit/drivers/openstack/watchers/test_nb_bgp_watcher.py | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/ovn_bgp_agent/drivers/openstack/watchers/nb_bgp_watcher.py b/ovn_bgp_agent/drivers/openstack/watchers/nb_bgp_watcher.py index d31331d5..4b3f9dec 100644 --- a/ovn_bgp_agent/drivers/openstack/watchers/nb_bgp_watcher.py +++ b/ovn_bgp_agent/drivers/openstack/watchers/nb_bgp_watcher.py @@ -665,9 +665,8 @@ class OVNLBCreateEvent(base_watcher.OVNLBEvent): vip_fip = self._get_vip_fip(row) old_vip_fip = self._get_vip_fip(old) with _SYNC_STATE_LOCK.read_lock(): - if hasattr(old, 'external_ids'): - if vip_fip and vip_fip != old_vip_fip: - self.agent.expose_ovn_lb_fip(row) + if hasattr(old, 'external_ids') and vip_fip != old_vip_fip: + self.agent.expose_ovn_lb_fip(row) else: self.agent.expose_ovn_lb_vip(row) diff --git a/ovn_bgp_agent/tests/unit/drivers/openstack/watchers/test_nb_bgp_watcher.py b/ovn_bgp_agent/tests/unit/drivers/openstack/watchers/test_nb_bgp_watcher.py index 4702ae15..88df8759 100644 --- a/ovn_bgp_agent/tests/unit/drivers/openstack/watchers/test_nb_bgp_watcher.py +++ b/ovn_bgp_agent/tests/unit/drivers/openstack/watchers/test_nb_bgp_watcher.py @@ -1198,7 +1198,7 @@ class TestOVNLBCreateEvent(test_base.TestCase): self.agent.expose_ovn_lb_vip.assert_called_once_with(row) self.agent.expose_ovn_lb_fip.assert_not_called() - def test_run_vip_added_extra_ext_id_info(self): + def test_run_vip_added_router(self): row = utils.create_row( external_ids={ constants.OVN_LB_LR_REF_EXT_ID_KEY: 'neutron-router1', @@ -1208,13 +1208,12 @@ class TestOVNLBCreateEvent(test_base.TestCase): vips={'vip': 'member', 'fip': 'member'}) old = utils.create_row( external_ids={ - constants.OVN_LB_LR_REF_EXT_ID_KEY: 'neutron-router1', constants.OVN_LB_VIP_FIP_EXT_ID_KEY: 'fip', constants.OVN_LS_NAME_EXT_ID_KEY: 'net1'}) self.event.run(None, row, old) - self.agent.expose_ovn_lb_vip.assert_not_called() + self.agent.expose_ovn_lb_vip.assert_called_once_with(row) self.agent.expose_ovn_lb_fip.assert_not_called() def test_run_fip(self):