-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minigraph ECMP parsing support (cleaner format) #4985
Conversation
need to add sonic-cfggen tests, please |
1288c68
to
29a69cc
Compare
retest mellanox please. |
retest mellanox please |
1 similar comment
retest mellanox please |
29a69cc
to
48a323d
Compare
retest mellanox please |
318355b
to
cb2c833
Compare
retest mellanox please |
1 similar comment
retest mellanox please |
src/sonic-config-engine/minigraph.py
Outdated
LCM = sum(lcm_array) | ||
FG_NHG_MEMBER[0] = {ip: {"FG_NHG": ipv4_tag, "Bank": bank} for ip, bank in nhipv4_bank_map.items()} | ||
FG_NHG_PREFIX[0] = {nhgaddr[0]: {"FG_NHG": ipv4_tag}} | ||
FG_NHG[0] = {ipv4_tag: {"hash_bucket_size": LCM}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change "hash_bucket_size" to "bucket_size" per schema
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed
src/sonic-config-engine/minigraph.py
Outdated
lcm_comp = lcm_comp * i / gcd(lcm_comp, i) | ||
lcm_array.append(lcm_comp) | ||
LCM = sum(lcm_array) | ||
FG_NHG_MEMBER[0] = {ip: {"FG_NHG": ipv4_tag, "Bank": bank} for ip, bank in nhipv4_bank_map.items()} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change "Bank" to "bank"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed
efb0339
to
1dab9c7
Compare
retests vsimage please |
retest vsimage please |
endport = link.find(str(QName(ns, "EndPort"))).text | ||
startdevice = link.find(str(QName(ns, "StartDevice"))).text | ||
port_device_map[endport] = startdevice | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest moving this logic to line 211, and utilizing the endport and startdevice values already generated on line 194 and 195.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe I had written like this to work around the already in-place lines of code in 190-191
dpg_ecmp_content = [] | ||
ipnhs = child.find(str(QName(ns, "IPNextHops"))) | ||
if ipnhs is not None: | ||
for ipnh in ipnhs.findall(str(QName(ns, "IPNextHop"))): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets add a check for IPNextHop type FineGrainedECMPGroupMember
src/sonic-config-engine/minigraph.py
Outdated
a = ipaddress.IPAddress(unicode(subnet_check_ip)) | ||
n = ipaddress.IPNetwork(unicode(subnet_range)) | ||
if (n.Contains(a)): | ||
nhgvlan = ip_intfs_map[subnet_range] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest that we rename the variable name, not necessary that it is a vlan
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i can use nhg_int if that is better
src/sonic-config-engine/minigraph.py
Outdated
nhgvlan = ip_intfs_map[subnet_range] | ||
dwnstrms = child.find(str(QName(ns, "DownstreamSummarySet"))) | ||
for dwnstrm in dwnstrms.findall(str(QName(ns, "DownstreamSummary"))): | ||
dwnstrmentry = str(ET.tostring(dwnstrm)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we use the QName based search/parse in the below section?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For that one specific section, very oddly, there were errors trying to do so. I will look into it again
src/sonic-config-engine/minigraph.py
Outdated
port_nhipv4_map = dpg_ecmp_content[0] | ||
port_nhipv6_map = dpg_ecmp_content[1] | ||
nhgaddr = dpg_ecmp_content[2] | ||
nhgvlan = dpg_ecmp_content[3] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change variable name since its not necessary that it is a vlan
nhdevices_bank_map = {device: bank for bank, device in enumerate(nhdevices)} | ||
nhipv4_bank_map = {ip: nhdevices_bank_map[device] for ip, device in nhipv4_device_map.items()} | ||
nhipv6_bank_map = {ip: nhdevices_bank_map[device] for ip, device in nhipv6_device_map.items()} | ||
for value in nhdevices_bank_map.values(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IPv4 and IPv6 could have a different enumeration of banks and as a result a different lcm. I would also suggest moving this calculation of lcm to a helper function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok will do this
1dab9c7
to
13beebc
Compare
retest vsimage please |
65c39a4
to
bfb5236
Compare
This pull request introduces 1 alert and fixes 10 when merging bfb5236488f4f5049f3c61650dc9a2c9b4874e10 into b595a6e - view on LGTM.com new alerts:
fixed alerts:
|
retest mellanox please |
dwnstrmentry = str(ET.tostring(dwnstrm)) | ||
if ("FineGrainedECMPGroupDestination" in dwnstrmentry): | ||
subnet_ip = dwnstrm.find(str(QName(ns1, "Subnet"))).text | ||
truncsubnet_ip = subnet_ip.split("/")[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to truncate it here for the IPv4/IPv6 check?
src/sonic-config-engine/minigraph.py
Outdated
port_nhipv4_map = dpg_ecmp_content[0] | ||
port_nhipv6_map = dpg_ecmp_content[1] | ||
nhgaddr = dpg_ecmp_content[2] | ||
nhg_int = dpg_ecmp_content[3] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: readability consideration, I would recommend making dpg_ecmp_content a dictionary instead of an array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed for dpg_ecmp_content as well as png_ecmp_content
retest mellanox please |
806610c
to
cf74368
Compare
retest mellanox please |
a = ipaddress.ip_address(UNICODE_TYPE(subnet_check_ip)) | ||
n = list(ipaddress.ip_network(UNICODE_TYPE(subnet_range), False).hosts()) | ||
if a in n: | ||
nhg_int = ip_intfs_map[subnet_range] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assumes a single interface for all IPs, though it may be addressed in a future PR: it is better to not to assume single interface associated with all IPs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see the comments and update it accordingly.
bf3e563
to
da29af4
Compare
f7678b3
to
d90543b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
3615e69
to
940dd94
Compare
retest vsimage please |
retest vsimage please |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
output = self.run_script(argument) | ||
self.assertEqual(output.strip(), "['200.200.200.1', '200.200.200.10', '200.200.200.2', '200.200.200.3', '200.200.200.4', '200.200.200.5'," | ||
" '200.200.200.6', '200.200.200.7', '200.200.200.8', '200.200.200.9', '200:200:200:200::1', '200:200:200:200::10'," | ||
" '200:200:200:200::2', '200:200:200:200::3', '200:200:200:200::4', '200:200:200:200::5', '200:200:200:200::6'," |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a future PR can we address adding checks for the values being populated in these entries(FG_NHG, link, and bank), having only the keys tested prevents 100% test coverage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do so
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me, I provided a comment on test improvement, I would recommend that for a follow up PR.
- Why I did it
To support FG_ECMP for certain azd scenarios
- How I did it
Modified minigraph parser to parse ECMP fields in the case they are present in minigraph
- How to verify it
Loaded ensuing config_db file on a DUT to verify the fields are parsed and configure device correctly
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)