-
Notifications
You must be signed in to change notification settings - Fork 9
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
CP-48447+CA-390127: correct exception handling for func_output callbacks, fix saving all log messages #92
Conversation
s = traceback.format_exc() | ||
log(s) | ||
backtrace = traceback.format_exc() # type: str | ||
log(backtrace) | ||
s = backtrace.encode() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the fix: It needs to convert the backtrace to bytes for the BytesIO
that is used by tarfile
and zipfile
to include the data in the output archive.
The other changes are only the enhancements for tests/, to cover the change and to verify the logging of such exceptions (and fix the spelling dictionary for spelling checks in CI)
Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
f6330e4
to
8187429
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #92 +/- ##
=====================================
+ Coverage 88% 91% +3%
=====================================
Files 18 19 +1
Lines 2196 2202 +6
=====================================
+ Hits 1939 2011 +72
+ Misses 257 191 -66
Flags with carried forward coverage won't be shown. Click here to find out more. |
…ive (xenserver#93) Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
Fix two issues (their tests overlap):
CA-390127 (fix saving all log messages)
Fix adding even the last log() messages to the output archive
xen-bugtool.main()
), the exception raised and logged as part of the test execution could not be found in thexen-bugtool.log
file that is recorded in thebugtool
output archive.xen-bugtool.log
file itself (not in the output archive)xen-bugtool.log
was collected before the exception was written to it:CP-48447 (correct exception handling for func_output callbacks)
A major design goal of
xen-bugtool
is to continue as well as possible when an error occurs.This is currently failing in a specific case when Python3 would be used to run
xen-bugtool
:func_output()
Traceback of an example (a real variant of caused me to notice it):
Initial exception (example):
This then results in a
str
(from the traceback) passed toio.BytesIO
without encoding to bytes first, causing the 2nd, fatal Exception:That's an issue that is detected by pyright:
https://github.com/marketplace/actions/run-pyright-with-reviewdog
https://github.com/jordemort/action-pyright