[cSONiC] Make show CLI work in docker-sonic-vs neighbors (no nested docker/rvtysh)#4633
Open
securely1g wants to merge 1 commit into
Open
[cSONiC] Make show CLI work in docker-sonic-vs neighbors (no nested docker/rvtysh)#4633securely1g wants to merge 1 commit into
securely1g wants to merge 1 commit into
Conversation
…ocker/rvtysh) In docker-sonic-vs containers used as cSONiC neighbors in the sonic-mgmt KVM testbed, FRR runs in the same container: there is no nested 'bgp' docker container and no 'rvtysh' wrapper. Two code paths assumed the real-SONiC layout and leaked errors / failed on every relevant 'show': 1. show/main.py::get_routing_stack() runs 'sudo docker ps ...' at module import time, so every 'show' invocation (even --help) printed 'sudo: docker: command not found'. Skip the one-liner when the docker binary is absent and keep the default 'frr'. 2. utilities_common/bgp_util.py::run_bgp_show_command() uses the 'rvtysh' wrapper, which execs into the nested bgp container on real SONiC. When 'rvtysh' is not in PATH, fall back to the plain 'vtysh' binary so commands like 'show ip route' / 'show ip bgp summary' work instead of failing with 'sudo: rvtysh: command not found'. Added unit tests in tests/show_test.py covering both the docker-present and docker-absent paths for get_routing_stack(), and the rvtysh-present and rvtysh-absent fallback for run_bgp_show_command(). Verified live on a cSONiC neighbor (docker-sonic-vs): 'show ip route' and 'show ip bgp summary' now return full output with no stderr leaks. Fixes sonic-net#4632 Signed-off-by: securely1g <securely1g@users.noreply.github.com>
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
In
docker-sonic-vscontainers used as cSONiC neighbors in the sonic-mgmt KVM testbed, FRR runs inside the same container — there is no nestedbgpdocker container and norvtyshwrapper. Twosonic-utilitiescode paths assume the real-SONiC layout, so every relevantshowcommand either leaks an error to stderr or fails outright:show/main.py::get_routing_stack()runs asudo docker ps ...one-liner at module import time (routing_stack = get_routing_stack()global). It therefore executes on everyshowinvocation — evenshow ... --help— printing:The
try/exceptdoes default to'frr', so the value is correct, but the stderr leak is unconditional. The function's own# To be enhancedcomment already flags this one-liner as undesirable.utilities_common/bgp_util.py::run_bgp_show_command()usesRVTYSH_COMMAND = 'rvtysh', the routing-stack-aware wrapper thatdocker execs into thebgpcontainer on real SONiC. Indocker-sonic-vsthe wrapper does not exist, so commands fail with:In a cSONiC neighbor only the plain
vtyshbinary exists (command -v rvtysh→ not found;command -v vtysh→/usr/bin/vtysh).Resolves #4632. This is the
sonic-utilitiescounterpart to the cSONiC neighbor-environment gaps tracked in sonic-mgmt (e.g. #22647, #22648).How I did it
get_routing_stack(): short-circuit and return the default'frr'when thedockerbinary is not present (shutil.which('docker') is None), so the bash one-liner never runs on single-container images and no stderr is leaked. Behavior on real SONiC (docker present) is unchanged.run_bgp_show_command(): select the vtysh wrapper at runtime — uservtyshwhen it is present inPATH(real SONiC), otherwise fall back to the plainvtyshbinary (docker-sonic-vs). No change to the argv/return contract.tests/show_test.py(TestCsonicNeighborEnv) covering both docker-present/absent paths ofget_routing_stack()and both rvtysh-present/absent paths ofrun_bgp_show_command().How to verify it
Run the new unit tests:
Manual verification on a live cSONiC neighbor (
docker-sonic-vs) — before vs after this change:Before:
After (verified):
Which release branch to backport (provide reason below if selected)
Description for the changelog
Make the
showCLI work indocker-sonic-vs(cSONiC) neighbor containers: skip thedocker psrouting-stack probe when docker is absent, and fall back fromrvtyshtovtyshwhen thervtyshwrapper is not present.