Merge "Ensure lbs are properly configured for router gateway set/unset"

This commit is contained in:
Zuul 2022-10-07 14:06:04 +00:00 committed by Gerrit Code Review
commit e90afca4a0
3 changed files with 28 additions and 7 deletions

View File

@ -36,8 +36,6 @@ class LogicalRouterPortEvent(row_event.RowEvent):
'%(event)s, %(row)s',
{'event': event,
'row': row})
if row.gateway_chassis:
return
if event == self.ROW_CREATE:
self.driver.lb_create_lrp_assoc_handler(row)
elif event == self.ROW_DELETE:

View File

@ -240,7 +240,8 @@ class OvnProviderHelper():
LOG.debug("Router or network information not found")
return
request_info = {'network': network,
'router': router}
'router': router,
'gateway_chassis': row.gateway_chassis}
self.add_request({'type': ovn_const.REQ_TYPE_LB_CREATE_LRP_ASSOC,
'info': request_info})
@ -257,6 +258,15 @@ class OvnProviderHelper():
lb.uuid, info['router'].uuid)
self._update_lb_to_lr_association_by_step(lb, info['router'])
# if gateway_chassis ports, there is no need to re-add the
# loadbalancers from the router into the provider network.
# This will be already done for loadbalancer created with VIPs on
# provider networks, regardless of the gateway_chassis lrp port
# existence. And it should never be there when the VIPs are on
# tenant networks.
if info['gateway_chassis']:
return
# Add those lb to the network which are unique to the router
for lb in (router_lb - network_lb):
try:

View File

@ -1895,7 +1895,8 @@ class TestOvnProviderHelper(ovn_base.TestOvnOctaviaBase):
expected = {
'info':
{'router': self.router,
'network': self.network},
'network': self.network,
'gateway_chassis': []},
'type': 'lb_create_lrp_assoc'}
self.mock_add_request.assert_called_once_with(expected)
@ -1920,7 +1921,13 @@ class TestOvnProviderHelper(ovn_base.TestOvnOctaviaBase):
row = fakes.FakeOvsdbRow.create_one_ovsdb_row(
attrs={'gateway_chassis': ['temp-gateway-chassis']})
self.router_port_event.run(mock.ANY, row, mock.ANY)
self.mock_add_request.assert_not_called()
expected = {
'info':
{'router': self.router,
'network': self.network,
'gateway_chassis': ['temp-gateway-chassis']},
'type': 'lb_create_lrp_assoc'}
self.mock_add_request.assert_called_once_with(expected)
def test__get_pool_listeners(self):
self._get_pool_listeners.stop()
@ -2090,12 +2097,14 @@ class TestOvnProviderHelper(ovn_base.TestOvnOctaviaBase):
self.router, delete=True)
def test_lb_create_lrp_assoc_handler(self):
lrp = fakes.FakeOvsdbRow.create_one_ovsdb_row()
lrp = fakes.FakeOvsdbRow.create_one_ovsdb_row(
attrs={'gateway_chassis': []})
self.helper.lb_create_lrp_assoc_handler(lrp)
expected = {
'info':
{'router': self.router,
'network': self.network},
'network': self.network,
'gateway_chassis': []},
'type': 'lb_create_lrp_assoc'}
self.mock_add_request.assert_called_once_with(expected)
@ -2114,6 +2123,7 @@ class TestOvnProviderHelper(ovn_base.TestOvnOctaviaBase):
info = {
'network': self.network,
'router': self.router,
'gateway_chassis': [],
}
self.helper.lb_create_lrp_assoc(info)
self.helper._update_lb_to_lr_association.assert_called_once_with(
@ -2124,6 +2134,7 @@ class TestOvnProviderHelper(ovn_base.TestOvnOctaviaBase):
info = {
'network': self.network,
'router': self.router,
'gateway_chassis': [],
}
self.helper._update_lb_to_ls_association.side_effect = [
idlutils.RowNotFound]
@ -2141,6 +2152,7 @@ class TestOvnProviderHelper(ovn_base.TestOvnOctaviaBase):
info = {
'network': self.network,
'router': self.router,
'gateway_chassis': 'fake-chassis',
}
self.helper._update_lb_to_lr_association.side_effect = [
idlutils.RowNotFound]
@ -2157,6 +2169,7 @@ class TestOvnProviderHelper(ovn_base.TestOvnOctaviaBase):
info = {
'network': self.network,
'router': self.router,
'gateway_chassis': 'fake-chassis',
}
# Make it already uniq.
self.network.load_balancer = self.router.load_balancer