Skip to content

Commit 094c9f1

Browse files
ralonsohmnasiadka
authored andcommitted
Use HA_Chassis_Group in the OVN L3 scheduler
TODO: * Testing NOTE: this method cannot be merged alone, it would need ``schedule_unhosted_gateways`` too and a migration strategy (a maintenance method) The NB API method ``schedule_new_gateway`` now creates a ``HA_Chassis_Group`` and its ``HA_Chassis`` registers, and associates it to the gateway ``Logical_Router_Port``. The usage og ``Gateway_Chassis`` is deprecated. Partial-Bug: #2092271 Change-Id: If38f405428a8b27bf551db48c4e96d75deeb09fc Signed-off-by: Rodolfo Alonso Hernandez <[email protected]>
1 parent d93c35f commit 094c9f1

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

neutron/common/ovn/utils.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,16 @@ def get_chassis_without_azs(chassis_list):
903903
get_chassis_availability_zones(ch)}
904904

905905

906+
def get_chassis_priority(chassis_list):
907+
"""Given a chassis list, returns a dictionary with chassis name and prio
908+
909+
The chassis list is ordered according to the priority: the first one is the
910+
highest priority chassis, the last one is the least priority chassis.
911+
"""
912+
return {chassis: prio + 1 for prio, chassis
913+
in enumerate(reversed(chassis_list))}
914+
915+
906916
def parse_ovn_lb_port_forwarding(ovn_rtr_lb_pfs):
907917
"""Return a dictionary compatible with port forwarding from OVN lb."""
908918
result = {}

neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/commands.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -432,9 +432,12 @@ def run_idl(self, txn):
432432
# the top.
433433
index = chassis.index(primary)
434434
chassis[0], chassis[index] = chassis[index], chassis[0]
435-
setattr(
436-
lrouter_port,
437-
*_add_gateway_chassis(self.api, txn, self.g_name, chassis))
435+
chassis_priority = utils.get_chassis_priority(chassis)
436+
lrouter_name = lrouter_port.external_ids[
437+
ovn_const.OVN_ROUTER_NAME_EXT_ID_KEY]
438+
hcg = _sync_ha_chassis_group(txn, self.api, lrouter_name,
439+
chassis_priority, may_exist=True)
440+
setattr(lrouter_port, 'ha_chassis_group', ovsdbapp_utils.get_uuid(hcg))
438441

439442

440443
class ScheduleNewGatewayCommand(command.BaseCommand):
@@ -459,8 +462,11 @@ def run_idl(self, txn):
459462
self.api, self.sb_api, self.g_name, candidates=candidates,
460463
target_lrouter=lrouter)
461464
if chassis:
462-
setattr(lrouter_port,
463-
*_add_gateway_chassis(self.api, txn, self.g_name, chassis))
465+
chassis_priority = utils.get_chassis_priority(chassis)
466+
hcg = _sync_ha_chassis_group(txn, self.api, self.lrouter_name,
467+
chassis_priority, may_exist=True)
468+
setattr(lrouter_port, 'ha_chassis_group',
469+
ovsdbapp_utils.get_uuid(hcg))
464470

465471

466472
class LrDelCommand(ovn_nb_commands.LrDelCommand):
@@ -1053,15 +1059,17 @@ def run_idl(self, txn):
10531059
# Remove the router pinning to a chassis (if any).
10541060
lrouter.delkey('options', 'chassis')
10551061

1056-
# Remove the HA_Chassis_Group of the router (if any).
1062+
for gw_port in self.api.get_lrouter_gw_ports(lrouter.name):
1063+
gw_port.ha_chassis_group = []
1064+
lrouter.delvalue('ports', gw_port)
1065+
1066+
# Remove the HA_Chassis_Group of the router (if any), after
1067+
# removing it from the gateway Logical_Router_Ports.
10571068
hcg = self.api.lookup('HA_Chassis_Group',
10581069
lrouter.name, default=None)
10591070
if hcg:
10601071
hcg.delete()
10611072

1062-
for gw_port in self.api.get_lrouter_gw_ports(lrouter.name):
1063-
lrouter.delvalue('ports', gw_port)
1064-
10651073

10661074
class SetLSwitchPortToVirtualTypeCommand(command.BaseCommand):
10671075
def __init__(self, api, lport, vip, parent, if_exists):

0 commit comments

Comments
 (0)