Add rotation capable logging tool for customized ansible modules#4302
Merged
wangxin merged 2 commits intosonic-net:masterfrom Sep 22, 2021
Merged
Add rotation capable logging tool for customized ansible modules#4302wangxin merged 2 commits intosonic-net:masterfrom
wangxin merged 2 commits intosonic-net:masterfrom
Conversation
Currently ansible/module_utils/debug_utils provided some functions for logging in customized ansible modules. There are two issues with current tool: 1. There is no log rotation. Currently the conn_graph_facts module is using this tool. Each call of the conn_graph_facts module would generate a log file to /tmp folder of the sonic-mgmt container. Massive number log files would be generated after couple rounds of nightly tests. 2. It is tedious to use the tool. This PR improved the existing logging tool in two ways: 1. Add log rotation support. It will keep the most recent 10 files at most. 2. Much more easier to use. Just import it and call it. Then we can use logging.debug, logging.info, etc., to log in customized modules. Signed-off-by: Xin Wang <[email protected]>
|
This pull request introduces 1 alert when merging 1b6fe59 into e916cb8 - view on LGTM.com new alerts:
|
4 tasks
yutongzhang-microsoft
added a commit
that referenced
this pull request
Oct 13, 2021
Description of PR Some homebrew ansible modules may generate log files to /tmp folder on the host that it was executed. These modules manage the log files by their own and do not support log rotation. A new log rotation capable module utility was added in #4302 Update below ansible modules to use the new tool for logging: ansible/roles/vm_set/library/sonic_kickstart.py ansible/roles/vm_set/library/ceos_network.py ansible/roles/vm_set/library/kickstart.py ansible/roles/vm_set/library/vm_topology.py What is the motivation for this PR? Use the new log rotation capable module utility which was added in #4302 to support log rotation. How did you do it? I import the new log rotation capable module utility at the front of each file and use it to support log rotation. Meanwhile, I delete the previous functions which were related to the log. How did you verify/test it? I use ./testbed-cli.sh add-topo, deploy-mg and remove-topo to test it. Signed-off-by: Yutong Zhang <[email protected]>
kazinator-arista
pushed a commit
to kazinator-arista/sonic-mgmt
that referenced
this pull request
Mar 4, 2026
…atically (#25595) #### Why I did it src/sonic-utilities ``` * ddc241ec - (HEAD -> 202511, origin/202511) [storm-control] Fixed show storm-control interface command display (sonic-net#4302) (32 hours ago) [mssonicbld] * fbd3f90b - [fast-reboot][cosmetic] Fixed debug/error prints with the correct reboot type (sonic-net#4286) (5 days ago) [Yair Raviv] * efdffa2a - Added counterpoll CLI support (sonic-net#4291) (6 days ago) [mssonicbld] * 567ad5b3 - [Smartswitch] Prevent early exit of reboot status (sonic-net#4287) (6 days ago) [mssonicbld] ``` #### How I did it #### How to verify it #### Description for the changelog
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.
Description of PR
Summary:
Fixes # (issue)
Type of change
Back port request
Approach
What is the motivation for this PR?
Currently ansible/module_utils/debug_utils provided some functions for logging
in customized ansible modules. There are two issues with current tool:
tool. Each call of the conn_graph_facts module would generate a log file to /tmp
folder of the sonic-mgmt container. Massive number log files would be generated
after couple rounds of nightly tests.
How did you do it?
This PR improved the existing logging tool in two ways:
logging.debug, logging.info, etc., to log in customized ansible modules.
How did you verify/test it?
Test run a script using the conn_graph_facts module over 10 times. Check the generated logs.
Any platform specific information?
Supported testbed topology if it's a new test case?
Documentation