From 096e4df5fc4458a02928c84b40ba01e66618b4ad Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Wed, 18 May 2022 18:54:27 +0000 Subject: [PATCH] "_handle_lb_fip_cmds" to handle the LB members correctly This patch indents the section where the load balancer members are properly verified. This section must be executed for each load balancer matching the logical switch port with the VIP passed as an argument to the method "_handle_lb_fip_cmds". Closes-Bug: #1977969 Change-Id: Ib220867106abc59da4fae51a60ef52d0c02592c8 --- .../ovn/mech_driver/ovsdb/ovn_client.py | 110 +++++++++--------- 1 file changed, 55 insertions(+), 55 deletions(-) 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 f52b532c297..f86dbc102ba 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 @@ -934,62 +934,62 @@ class OVNClient(object): "for OVN LB member " "%s.", m['id']) - # Find a member LSPs from all linked LS to this LB. - for member in members_to_verify: - ls = self._nb_idl.lookup( - 'Logical_Switch', utils.ovn_name(member['network_id'])) - for lsp in ls.ports: - if not lsp.addresses: - continue - if member['ip'] in utils.remove_macs_from_lsp_addresses( - lsp.addresses): - member['lsp'] = lsp - nats = self._nb_idl.db_find_rows( - 'NAT', - ('external_ids', '=', { - ovn_const.OVN_FIP_PORT_EXT_ID_KEY: lsp.name}) - ).execute(check_error=True) + # Find a member LSPs from all linked LS to this LB. + for member in members_to_verify: + ls = self._nb_idl.lookup( + 'Logical_Switch', utils.ovn_name(member['network_id'])) + for lsp in ls.ports: + if not lsp.addresses: + continue + if member['ip'] in utils.remove_macs_from_lsp_addresses( + lsp.addresses): + member['lsp'] = lsp + nats = self._nb_idl.db_find_rows( + 'NAT', + ('external_ids', '=', { + ovn_const.OVN_FIP_PORT_EXT_ID_KEY: lsp.name}) + ).execute(check_error=True) - for nat in nats: - if action == ovn_const.FIP_ACTION_ASSOCIATE: - # NOTE(mjozefcz): We should delete logical_port - # and external_mac entries from member NAT in - # order to make traffic work. - LOG.warning( - "Port %s is configured as a member " - "of one of OVN Load_Balancers and " - "Load_Balancer has FIP assigned. " - "In order to make traffic work member " - "FIP needs to be centralized, even if " - "this environment is configured as " - "DVR. Removing logical_port and " - "external_mac from NAT entry.", - lsp.name) - commands.extend([ - self._nb_idl.db_clear( - 'NAT', nat.uuid, 'external_mac'), - self._nb_idl.db_clear( - 'NAT', nat.uuid, 'logical_port')]) - else: - # NOTE(mjozefcz): The FIP from LB VIP is - # dissassociated now. We can decentralize - # member FIPs now. - LOG.warning( - "Port %s is configured as a member " - "of one of OVN Load_Balancers and " - "Load_Balancer has FIP disassociated. " - "DVR for this port can be enabled back.", - lsp.name) - commands.append(self._nb_idl.db_set( - 'NAT', nat.uuid, - ('logical_port', lsp.name))) - port = self._plugin.get_port(context, lsp.name) - if port['status'] == const.PORT_STATUS_ACTIVE: - commands.append( - self._nb_idl.db_set( - 'NAT', nat.uuid, - ('external_mac', - port['mac_address']))) + for nat in nats: + if action == ovn_const.FIP_ACTION_ASSOCIATE: + # NOTE(mjozefcz): We should delete logical_port + # and external_mac entries from member NAT in + # order to make traffic work. + LOG.warning( + "Port %s is configured as a member " + "of one of OVN Load_Balancers and " + "Load_Balancer has FIP assigned. " + "In order to make traffic work member " + "FIP needs to be centralized, even if " + "this environment is configured as " + "DVR. Removing logical_port and " + "external_mac from NAT entry.", + lsp.name) + commands.extend([ + self._nb_idl.db_clear( + 'NAT', nat.uuid, 'external_mac'), + self._nb_idl.db_clear( + 'NAT', nat.uuid, 'logical_port')]) + else: + # NOTE(mjozefcz): The FIP from LB VIP is + # dissassociated now. We can decentralize + # member FIPs now. + LOG.warning( + "Port %s is configured as a member " + "of one of OVN Load_Balancers and " + "Load_Balancer has FIP disassociated. " + "DVR for this port can be enabled back.", + lsp.name) + commands.append(self._nb_idl.db_set( + 'NAT', nat.uuid, + ('logical_port', lsp.name))) + port = self._plugin.get_port(context, lsp.name) + if port['status'] == const.PORT_STATUS_ACTIVE: + commands.append( + self._nb_idl.db_set( + 'NAT', nat.uuid, + ('external_mac', + port['mac_address']))) return commands