Skip to content

Commit 20a8468

Browse files
authored
[action] [PR:19340] [routes] Add sorting vms in announce_routes for t0 and t1 (sonic-net#490)
<!-- Please make sure you've read and understood our contributing guidelines; https://github.com/sonic-net/SONiC/blob/gh-pages/CONTRIBUTING.md Please provide following information to help code review process a bit easier: --> ### Description of PR <!-- - Please include a summary of the change and which issue is fixed. - Please also include relevant motivation and context. Where should reviewer start? background context? - List any dependencies that are required for this change. --> Summary: Fixes # (issue) ### Type of change <!-- - Fill x for your type of change. - e.g. - [x] Bug fix --> - [ ] Bug fix - [ ] Testbed and Framework(new/improvement) - [ ] New Test case - [ ] Skipped for non-supported platforms - [ ] Test case improvement ### Back port request - [ ] 202205 - [ ] 202305 - [ ] 202311 - [ ] 202405 - [ ] 202411 - [ ] 202505 ### Approach #### What is the motivation for this PR? Below PRs added support to advertise different route sets from BGP neighbors for T0 / T1, it's based on vm index. But loading dict from yml cannot guarantee the sort always be the same. If we re-announce routes or withdraw routes after order changing, the result would be incorrect. sonic-net#19117 sonic-net#19041 #### How did you do it? Add sorted in vm index to make sure order of vm dict would always be the same #### How did you verify/test it? Run tests #### Any platform specific information? #### Supported testbed topology if it's a new test case? ### Documentation <!-- (If it's a new feature, new test case) Did you update documentation/Wiki relevant to your implementation? Link to the wiki page? -->
1 parent 869c456 commit 20a8468

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

ansible/library/announce_routes.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,8 @@ def fib_t0(topo, ptf_ip, no_default_route=False, action="announce", upstream_nei
517517
vms_len = len(vms)
518518
current_routes_offset = 0
519519
last_suffix = 0
520-
for index, (vm_name, vm) in enumerate(vms.items()):
520+
for index, vm_name in enumerate(sorted(vms.keys())):
521+
vm = vms[vm_name]
521522
router_type = "leaf"
522523
if 'tor' in topo['configuration'][vm_name]['properties']:
523524
router_type = 'tor'
@@ -651,7 +652,8 @@ def fib_t1_lag(topo, ptf_ip, topo_name, no_default_route=False, action="announce
651652
tor_number = len([k for k, v in vms_config.items() if 'tor' in v['properties']])
652653
lov6_address_pattern = ipv6_address_pattern.split("/")[0] + "/128"
653654
current_routes_offset = last_suffix
654-
for index, (k, v) in enumerate(vms_config.items()):
655+
for index, k in enumerate(sorted(vms_config.keys())):
656+
v = vms_config[k]
655657
if dpus and k in dpus:
656658
continue
657659
vm_offset = vms[k]['vm_offset']

0 commit comments

Comments
 (0)