Skip to content
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

route_check: Skip route checks if bgp feature is not enabled #3075

Merged
merged 6 commits into from
Dec 23, 2023

Conversation

anamehra
Copy link
Contributor

@anamehra anamehra commented Dec 10, 2023

If bgp is not enabled, get_frr_routes() gets empty list and route check fails and throws a traceback. Adding check to to skip route checks bgp feature is disabled. On the Chassis supervisor, bgp may be disabled.

Signed-off-by: Anand Mehra anamehra@cisco.com

What I did

Fixes sonic-net/sonic-buildimage#17400

Fixed the route_check.py traceback error on Chassis Supervisor.

How I did it

Added feature bgp check before performing frr route check. This prevents failure when bgp is not enabled on Supervisor.

How to verify it

run route_check.py on Supervisor. No traceback should be observed.

Previous command output (if the output of a command-line utility has changed)

root@sonic:/home/cisco# route_check.py 
Traceback (most recent call last):
  File "/usr/local/bin/route_check.py", line 822, in <module>
    sys.exit(main()[0])
  File "/usr/local/bin/route_check.py", line 809, in main
    ret, res= check_routes()
  File "/usr/local/bin/route_check.py", line 757, in check_routes
    rt_frr_miss = check_frr_pending_routes()
  File "/usr/local/bin/route_check.py", line 547, in check_frr_pending_routes
    frr_routes = get_frr_routes()
  File "/usr/local/bin/route_check.py", line 343, in get_frr_routes
    output = subprocess.check_output('show ip route json', shell=True)
  File "/usr/lib/python3.9/subprocess.py", line 424, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/lib/python3.9/subprocess.py", line 528, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command 'show ip route json' returned non-zero exit status 1.

New command output (if the output of a command-line utility has changed)

root@sonic:/home/cisco# route_check.py 
root@sonic:/home/cisco# 

Which release branch to backport (provide reason below if selected)

  • 202305

If bgp is not enabled, get_frr_routes() gets empty list and route check fails and throws a traceback. Adding check to check for frr routes only when bgp feature is enabled. On the Chassis supervisor, bgp may be disabled. 

Signed-off-by: Anand Mehra anamehra@cisco.com
@anamehra anamehra marked this pull request as draft December 10, 2023 06:26
Signed-off-by: Anand Mehra <anamehra@cisco.com>
@anamehra anamehra marked this pull request as ready for review December 10, 2023 21:42
@anamehra
Copy link
Contributor Author

Hi @abdosi , @gechiang , @rlhui , this PR is ready for review. Needed for 202305. Thanks

@rlhui
Copy link
Contributor

rlhui commented Dec 13, 2023

only an issue from 202305 up

@deepak-singhal0408
Copy link
Contributor

@anamehra can you resolve the conflicts? The files have been modified for multi-asic support...

@deepak-singhal0408
Copy link
Contributor

KeyError: 'namespace-list'

Stack trace
self = <tests.route_check_test.TestRouteCheck object at 0x7f04c0d0bf10>
mock_dbs = None, test_num = '21'

@pytest.mark.parametrize("test_num", TEST_DATA.keys())
def test_route_check(self, mock_dbs, test_num):
    logger.debug("test_route_check: test_num={}".format(test_num))
    self.init()
    ret = 0
    ct_data = TEST_DATA[test_num]
    set_test_case_data(ct_data)
  self.run_test(ct_data)

tests/route_check_test.py:240:


self = <tests.route_check_test.TestRouteCheck object at 0x7f04c0d0bf10>
ct_data = {'Description': 'basic route check, good one, bgp disabled', 'args': 'route_check -m INFO -i 1000', 'pre-value': {0: {...":"oid:0x3000000000023"}': {}}}, 4: {'DEVICE_METADATA': {'localhost': {}}, 'FEATURE': {'bgp': {'state': 'disabled'}}}}}

def run_test(self, ct_data):
    with patch('sys.argv', ct_data[ARGS].split()), \
      patch('sonic_py_common.multi_asic.get_namespace_list', return_value= ct_data[NAMESPACE]), \
        patch('sonic_py_common.multi_asic.is_multi_asic', return_value= ct_data[MULTI_ASIC]), \
        patch('route_check.subprocess.check_output', side_effect=lambda *args, **kwargs: self.mock_check_output(ct_data, *args, **kwargs)), \
        patch('route_check.mitigate_installed_not_offloaded_frr_routes', side_effect=lambda *args, **kwargs: None), \
        patch('route_check.load_db_config', side_effect=lambda: init_db_conns(ct_data[NAMESPACE])):

E KeyError: 'namespace-list'

tests/route_check_test.py:244: KeyError

@anamehra
Copy link
Contributor Author

Hi @deepak-singhal0408 , I am checking on the errors after the conflict merge.

@anamehra anamehra marked this pull request as draft December 20, 2023 02:29
@anamehra anamehra marked this pull request as ready for review December 21, 2023 19:53
@anamehra
Copy link
Contributor Author

@deepak-singhal0408 , please review. Thanks!

@abdosi
Copy link
Contributor

abdosi commented Dec 21, 2023

@anamehra : can we skip complete script execution if bgp feature is disable and not tied with only FRR related checks.

Reason for this request in future someone can add more checks based on FRR so possible we will hit similar issue again. Skipping at top level will help in such cases

Copy link
Contributor

@abdosi abdosi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as per above comment.

Signed-off-by: anamehra <anamehra@cisco.com>
@anamehra anamehra changed the title Check for frr routes only when feature bgp is enabled route_check: Skip route checks if bgp feature is not enabled Dec 22, 2023
@abdosi abdosi merged commit 529bb96 into sonic-net:master Dec 23, 2023
5 checks passed
@abdosi
Copy link
Contributor

abdosi commented Dec 23, 2023

@anamehra please create PR for 202305.

@anamehra
Copy link
Contributor Author

@anamehra please create PR for 202305.

Thanks for merging this @abdosi ! 202305 needs #3077. I think that is also the reason for cherry pick conflict.
Please also tag both these PRs for 202311
Thanks

@StormLiangMS
Copy link
Contributor

@anamehra cherry pick conflict, pls resubmit separate PR to 202305.

@anamehra
Copy link
Contributor Author

anamehra commented Jan 8, 2024

@anamehra cherry pick conflict, pls resubmit separate PR to 202305.

Sure, will do after #3077 gets merged in 202305. Thanks

@yxieca
Copy link
Contributor

yxieca commented Jan 15, 2024

@anamehra @deepak-singhal0408 #3075 and #3077 have blocked sonic-utilities repo sub-module advance in sonic-buildimage repo.

@deepak-singhal0408
Copy link
Contributor

Hi @anamehra , could you resubmit this PR? It was reverted earlier.. Thanks!

@saksarav-nokia
Copy link
Contributor

@anamehra , is this resubmitted?

@deepak-singhal0408
Copy link
Contributor

Hi @anamehra , we are waiting on this PR.. if you are busy, please let me know, we can create this PR.. Thanks..

@anamehra
Copy link
Contributor Author

Hi @anamehra , we are waiting on this PR.. if you are busy, please let me know, we can create this PR.. Thanks..

#3270
Please review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[202305] [chassis]: route_check.py fails and throw traceback on Supervisor
8 participants