[TS/TSA/B/C]: Update traffic-shift scripts with bgp neighbor check enhancement #8990
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why I did it
The test case
test_TSA_B_C_with_no_neighbors
from bgp/test_traffic_shift.py may fail because of the way ebgp neighbors are counted in sonic-buildimage/dockers/docker-fpm-frr/TSA in source code or /usr/bin/TSA in bgp container (the same applies to TSB and TSC as well). Our (LinkedIn) configuration profile is a bit different, but the issue should be common.If there is no eBGP neighbor, TSA/TSB/TSC are supposed to return "System Mode: No external neighbors". However, this "no eBGP" check is done by looking at the number of route-maps from running-config.
In buildimage/dockers/docker-fpm-frr/TSA:
In buildimage/dockers/docker-fpm-frr/TS:
The idea is to find out the number of ebgp neighbors by checking if any ebgp-specific outbound route-maps are being used by any neighbors. However, this can be problematic and lead to incorrect result, in twofold:
How I did it
We can get the eBGP neighbor count by checking "show bgp summary". This proposal introduces a function
find_num_ebgp_neighbors
to parse "show bgp summary json" output and return the number of eBGP neighbors (remote-ASN different from local-ASN).How to verify it
case test_TSA_B_C_with_no_neighbors
from bgp/test_traffic_shift.py.Which release branch to backport (provide reason below if selected)
Description for the changelog
Update traffic-shift scripts with bgp neighbor check enhancement.
A picture of a cute animal (not mandatory but encouraged)