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

[flashing scripts] Log errors from subprocesses #15593

Merged
merged 1 commit into from
Feb 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion scripts/flashing/firmware_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,15 @@ def run_tool(self,
capture_output=True)
else:
result = self
self.err = subprocess.call(command)
self.error = subprocess.check_call(command)
except subprocess.CalledProcessError as exception:
self.err = exception.returncode
if capture_output:
self.log(fail_level, '--- stdout ---')
self.log(fail_level, exception.stdout)
self.log(fail_level, '--- stderr ---')
self.log(fail_level, exception.stderr)
self.log(fail_level, '---')
Comment on lines +228 to +232
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: shouldn't be better to have only one single log entry?

Suggested change
self.log(fail_level, '--- stdout ---')
self.log(fail_level, exception.stdout)
self.log(fail_level, '--- stderr ---')
self.log(fail_level, exception.stderr)
self.log(fail_level, '---')
self.log(fail_level, '--- stdout ---\n'
f'{exception.stdout}\n--- stderr ---\n'
f'{exception.stderr}\n---')

Copy link
Contributor

Choose a reason for hiding this comment

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

Lets follow up in a separate PR if needed. I would like to have this version in to catch the reason of the flakyness. In most cases these logs will not be used.

Copy link
Contributor

Choose a reason for hiding this comment

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

Unresolved after merge. @kpschoedel could you followup in a separate PR or argue that it is not needed?

there would also be the option of 'every stdout/stderr line should have its own log line' so that things align nicely in logs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I'll address this one way or another, when we catch the parttool error or separately.

except FileNotFoundError as exception:
self.err = exception.errno
if self.err == errno.ENOENT:
Expand Down