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

[announce_routes] localhost.announce_routes doesn't work with log_path="logs" parameter #16075

Open
AntonHryshchuk opened this issue Dec 15, 2024 · 5 comments

Comments

@AntonHryshchuk
Copy link
Contributor

Issue Description

The call of localhost.announce_routes doesn't work with parameter log_path="logs"

Results you see

The only place where the non-default log_path value is in test tests/stress/test_stress_routes.py:line 25

localhost.announce_routes(topo_name=topo_name, ptf_ip=ptf_ip, action="announce", path="../ansible/",
                              log_path="logs")

In this place we got the error:

tests.common.errors.RunAnsibleModuleFail: run module announce_routes failed, Ansible Results =>
failed = True
module_stdout = 
module_stderr = Traceback (most recent call last):
  File "/tmp/.ansible-AzDevOps/ansible-tmp-1734123097.5179994-11927-36100773310450/AnsiballZ_announce_routes.py", line 107, in <module>
    _ansiballz_main()
  File "/tmp/.ansible-AzDevOps/ansible-tmp-1734123097.5179994-11927-36100773310450/AnsiballZ_announce_routes.py", line 99, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/tmp/.ansible-AzDevOps/ansible-tmp-1734123097.5179994-11927-36100773310450/AnsiballZ_announce_routes.py", line 47, in invoke_module
    runpy.run_module(mod_name='ansible.modules.announce_routes', init_globals=dict(_module_fqn='ansible.modules.announce_routes', _modlib_path=modlib_path),
  File "/usr/lib/python3.8/runpy.py", line 207, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib/python3.8/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_announce_routes_payload_f_ob72zm/ansible_announce_routes_payload.zip/ansible/modules/announce_routes.py", line 1096, in <module>
  File "/tmp/ansible_announce_routes_payload_f_ob72zm/ansible_announce_routes_payload.zip/ansible/modules/announce_routes.py", line 1049, in main
  File "/tmp/ansible_announce_routes_payload_f_ob72zm/ansible_announce_routes_payload.zip/ansible/module_utils/debug_utils.py", line 40, in config_module_logging
FileNotFoundError: [Errno 2] No such file or directory: 'logs'

exception = Traceback (most recent call last):
  File "/tmp/.ansible-AzDevOps/ansible-tmp-1734123097.5179994-11927-36100773310450/AnsiballZ_announce_routes.py", line 107, in <module>
    _ansiballz_main()
  File "/tmp/.ansible-AzDevOps/ansible-tmp-1734123097.5179994-11927-36100773310450/AnsiballZ_announce_routes.py", line 99, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/tmp/.ansible-AzDevOps/ansible-tmp-1734123097.5179994-11927-36100773310450/AnsiballZ_announce_routes.py", line 47, in invoke_module
    runpy.run_module(mod_name='ansible.modules.announce_routes', init_globals=dict(_module_fqn='ansible.modules.announce_routes', _modlib_path=modlib_path),
  File "/usr/lib/python3.8/runpy.py", line 207, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib/python3.8/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_announce_routes_payload_f_ob72zm/ansible_announce_routes_payload.zip/ansible/modules/announce_routes.py", line 1096, in <module>
  File "/tmp/ansible_announce_routes_payload_f_ob72zm/ansible_announce_routes_payload.zip/ansible/modules/announce_routes.py", line 1049, in main
  File "/tmp/ansible_announce_routes_payload_f_ob72zm/ansible_announce_routes_payload.zip/ansible/module_utils/debug_utils.py", line 40, in config_module_logging
FileNotFoundError: [Errno 2] No such file or directory: 'logs'

msg = MODULE FAILURE
See stdout/stderr for the exact error
rc = 1
_ansible_no_log = None
changed = False
stdout =
stderr =

Test passed without parameter log_path="logs"

Introduced in #13492

Results you expected to see

Test localhost.announce_routes can work with parameter log_path

Is it platform specific

generic

Relevant log output

No response

Output of show version

No response

Attach files (if any)

No response

@AntonHryshchuk
Copy link
Contributor Author

@yxieca
Copy link
Collaborator

yxieca commented Jan 8, 2025

@yutongzhang-microsoft did we create 'logs' folder in pretest or pipeline? Why is it not failing in general?

@yutongzhang-microsoft
Copy link
Contributor

Hi, @yxieca, I think this issue is because there is no folcer tests/logs in their local environment. We create logs folder in https://github.com/sonic-net/sonic-mgmt/blob/master/tests/run_tests.sh#L218 if we use run_test.sh.

In PR #13492, I added an optional parameter in library announce_routes.py , which is only used in this script to redirect the logs of announcing route. For general situations, they don't use this parameter, so everything is as same as before.

@AntonHryshchuk Can you show me your command of executing this script?

@AntonHryshchuk
Copy link
Contributor Author

Hi @yutongzhang-microsoft
the test cmd:
python3 -m pytest ****/sonic-mgmt/tests/stress/test_stress_routes.py::test_announce_withdraw_route --inventory="../ansible/inventory,../ansible/veos" --host-pattern **** --module-path ../ansible/library/ --testbed ****-t0-c256 --testbed_file ../ansible/testbed.yaml --allow_recover --assert plain --log-cli-level debug --show-capture=no -ra --showlocals -v --completeness_level=confident --topology t0,any,util --skip_sanity --dynamic_update_skip_reason --random_seed=1734122964

the command from the test output:
DEBUG tests.common.devices.base:base.py:71 /root/mars/workspace/sonic-mgmt/tests/stress/test_stress_routes.py::announce_withdraw_routes#24: [localhost] AnsibleModule::announce_routes, args=[], kwargs={"topo_name": "t0-c256", "ptf_ip": "10.215.22.3", "action": "announce", "path": "../ansible/", "log_path": "logs"}

DEBUG tests.common.devices.base:base.py:108 /root/mars/workspace/sonic-mgmt/tests/stress/test_stress_routes.py::announce_withdraw_routes#24: [localhost] AnsibleModule::announce_routes Result => {"failed": true, "module_stdout": "", "module_stderr": "Traceback (most recent call last):\n File \"/tmp/.ansible-AzDevOps/ansible-tmp-1734123097.5179994-11927-36100773310450/AnsiballZ_announce_routes.py\", line 107........

@yutongzhang-microsoft
Copy link
Contributor

Hi @yutongzhang-microsoft the test cmd: python3 -m pytest ****/sonic-mgmt/tests/stress/test_stress_routes.py::test_announce_withdraw_route --inventory="../ansible/inventory,../ansible/veos" --host-pattern **** --module-path ../ansible/library/ --testbed ****-t0-c256 --testbed_file ../ansible/testbed.yaml --allow_recover --assert plain --log-cli-level debug --show-capture=no -ra --showlocals -v --completeness_level=confident --topology t0,any,util --skip_sanity --dynamic_update_skip_reason --random_seed=1734122964

the command from the test output: DEBUG tests.common.devices.base:base.py:71 /root/mars/workspace/sonic-mgmt/tests/stress/test_stress_routes.py::announce_withdraw_routes#24: [localhost] AnsibleModule::announce_routes, args=[], kwargs={"topo_name": "t0-c256", "ptf_ip": "10.215.22.3", "action": "announce", "path": "../ansible/", "log_path": "logs"}

DEBUG tests.common.devices.base:base.py:108 /root/mars/workspace/sonic-mgmt/tests/stress/test_stress_routes.py::announce_withdraw_routes#24: [localhost] AnsibleModule::announce_routes Result => {"failed": true, "module_stdout": "", "module_stderr": "Traceback (most recent call last):\n File \"/tmp/.ansible-AzDevOps/ansible-tmp-1734123097.5179994-11927-36100773310450/AnsiballZ_announce_routes.py\", line 107........

Can you add --log-file='logs/stress/test_stress_routes.log' into the command and have a try?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants