-
Notifications
You must be signed in to change notification settings - Fork 753
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
Fix loganalyzer.py UnicodeDecodeError issue #6524
Fix loganalyzer.py UnicodeDecodeError issue #6524
Conversation
Signed-off-by: Zhaohui Sun <[email protected]>
The pre-commit check detected issues in the files touched by this pull request. For old issues, it is not mandatory to fix them because they were not caused by this change. It is unfair to blame Detailed pre-commit check results: To run the pre-commit checks locally, you can follow below steps:
|
What is the motivation for this PR? Fix "UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc0 in position 2203: invalid start byte" when running loganalyzer.py on dut. master and 202205 can hit this issue if syslog contains non-ascii characters. How did you do it? Add errors='ignore' parameter when open syslog file. How did you verify/test it? Run platform_tests/api/test_fan_drawer_fans.py::test_get_status and enable loganalyzer. Signed-off-by: Zhaohui Sun <[email protected]>
…" (#6611) Reverts #6577 It blocks smoke test since the image fix sonic-net/sonic-buildimage#12425 is not in internal branch.
…" (#6611) Reverts #6577 It blocks smoke test since the image fix sonic-net/sonic-buildimage#12425 is not in internal branch.
What is the motivation for this PR? Fix "UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc0 in position 2203: invalid start byte" when running loganalyzer.py on dut. master and 202205 can hit this issue if syslog contains non-ascii characters. How did you do it? Add errors='ignore' parameter when open syslog file. How did you verify/test it? Run platform_tests/api/test_fan_drawer_fans.py::test_get_status and enable loganalyzer. Signed-off-by: Zhaohui Sun <[email protected]>
…c-net#6577) This reverts commit 94ac4a0.
…" (sonic-net#6577)" (sonic-net#6611) Reverts sonic-net#6577 It blocks smoke test since the image fix sonic-net/sonic-buildimage#12425 is not in internal branch.
Reverts #6524. Since the change sonic-net/sonic-buildimage#12425 was merged into internal branch. Revert this fix to make sure we can capture invalid format characters in syslog.
Reverts #6524. Since the change sonic-net/sonic-buildimage#12425 was merged into internal branch. Revert this fix to make sure we can capture invalid format characters in syslog.
What is the motivation for this PR? Fix "UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc0 in position 2203: invalid start byte" when running loganalyzer.py on dut. master and 202205 can hit this issue if syslog contains non-ascii characters. How did you do it? Add errors='ignore' parameter when open syslog file. How did you verify/test it? Run platform_tests/api/test_fan_drawer_fans.py::test_get_status and enable loganalyzer. Signed-off-by: Zhaohui Sun <[email protected]>
…c-net#6577) This reverts commit 94ac4a0.
Signed-off-by: Zhaohui Sun [email protected]
Description of PR
Summary:
Fixes # (issue)
If syslog contains some non-ascii character such as '\xc0\xaa\xd8w\xfc\x7f', then in python3, it can't decode it with utf-8. Please see this doc for more explanation.
https://blog.finxter.com/fixed-unicodedecodeerror-utf8-codec-cant-decode-byte-0xa5-in-position-0-invalid-start-byte/
Previous log looks like this:
/var/log/syslog.3.gz:Oct 13 04:26:29.526576 str-msn2700-03 ALERT dhcp_relay#dhcpmon[39]: dhcpmon detected disparity in DHCP Relay behavior. Duration: 432 (sec) for vlan: 'Agg-Vlan1000'
Currently log looks like this:
Oct 12 04:20:05.395531 str-msn2700-03 ALERT dhcp_relay#dhcpmon[39]: dhcpmon detected disparity in DHCP Relay behavior. Duration: 41634 (sec) for vlan: '\xc0\xaa\xd8w\xfc\x7f'
Changes are in this PR:
Add Structured Events w/ YANG Models by zbud-msft · Pull Request #12270 · sonic-net/sonic-buildimage (github.com)
Type of change
Back port request
Approach
What is the motivation for this PR?
Fix "
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc0 in position 2203: invalid start byte
" when running loganalyzer.py on dut.master and 202205 can hit this issue if syslog contains non-ascii characters.
How did you do it?
Add
errors='ignore'
parameter when open syslog file.How did you verify/test it?
Run
platform_tests/api/test_fan_drawer_fans.py::test_get_status
and enable loganalyzer.Any platform specific information?
Supported testbed topology if it's a new test case?
Documentation