sonic-net / sonic-mgmt

Configuration management examples for SONiC
Other
173 stars 689 forks source link

refactor: combine single and multi asic bgp check #13536

Closed cyw233 closed 1 day ago

cyw233 commented 6 days ago

Description of PR

Refactor the BGP check in config_reload.py to combine the single and multi asic scenarios into one.

Summary: Fixes # (issue) Microsoft ADO 28459397

Type of change

Back port request

Approach

What is the motivation for this PR?

In the previous PR #13471, we added multi asic support when wait_for_bgp is True in common/config_reload.py. It turns out we don't need to differentiate the single and multi asic scenarios. For a single asic Testbed, we can also use the sonic_host.get_bgp_neighbors_per_asic() and sonic_host.check_bgp_session_state_all_asics() to confirm the BGP session status.

One thing we need to be aware of is that sonic_host.get_bgp_neighbors_per_asic() will return a dictionary with None as the key for a single asic Testbed. This is because for a single asic Testbed, its default namespace is always None, but any hashable value is a valid Python dictionary key, so it should be fine to use None as the key.

How did you do it?

How did you verify/test it?

I manually ran the config_reload(..., wait_for_bgp=True) function in a single asic Testbed, and I can confirm it's working fine.

Any platform specific information?

Supported testbed topology if it's a new test case?

Documentation

mssonicbld commented 1 day ago

Cherry-pick PR to 202405: https://github.com/sonic-net/sonic-mgmt/pull/13590