-
Notifications
You must be signed in to change notification settings - Fork 404
run.py: stop hiding sandbox and recommend --debug on sandbox failure #4068
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
Conversation
As discussed in systemd#3948 and systemd#3992, logging commands failing in a sandbox without ever mentioning that a sandbox was in use is misleading and very time-consuming; notably because paths look real but they are not. To remove this confusion and cost, simply add one short line mentioning that a sandbox was involved when the failure happened + recommend to re-run with --debug to display bind mounts and other important information. Also separate the command and error message on different lines for better readability and re-usability. Just for the record: before commit 7e7a3c7 ("Don't log sandbox for every command"), `run.py` was logging sandbox commands every time which was too verbose and unreadable. That commit said "... but still log the full sandbox if a command fails" and it did that do in `__init__.py` - but not always in `run.py`. After that commit, the sandbox was logged by `run.py` only in --debug mode and became completely invisible otherwise. Signed-off-by: Marc Herbert <[email protected]>
7ae25d2 to
2a19d45
Compare
| if ARG_DEBUG.get(): | ||
| # Complete but very long and hard to read. It could be reusable. | ||
| logging.error(f"{shlex.join(['mkosi-sandbox', *sandbox, *cmdline])}") | ||
| else: | ||
| logging.error("sandbox command omitted, rerun with --debug to see full command with bind mounts") | ||
| logging.error(f"{shlex.join(cmdline)}") |
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.
Please stick to a single call to logging.error() and use newlines instead. I would keep the original log message the same and if --debug is not set, simply append another line that says the following:
"sandbox details omitted, rerun with --debug to see the full sandbox command."
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.
... and use newlines instead. I would keep the original log message the same...
So are you ok with printing the error message on a separate line? Adding just one newline. Not 100% clear to me from the above, sorry.
I tested this PR heavily (especially compared to how small of a code change it is...) and NOT having the error message trailing a 5-10 lines-long command made a massive difference. It's quite painful to find before this PR.
I don't mind the code style and the number of logging statements, the terminal output and "user experience" is really the purpose of this.
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.
Thanks for the prompt review which... I missed! Sorry for the belated reply.
| if ARG_DEBUG.get(): | ||
| # Complete but very long and hard to read. It could be reusable. | ||
| logging.error(f"{shlex.join(['mkosi-sandbox', *sandbox, *cmdline])}") | ||
| else: | ||
| logging.error("sandbox command omitted, rerun with --debug to see full command with bind mounts") | ||
| logging.error(f"{shlex.join(cmdline)}") |
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.
... and use newlines instead. I would keep the original log message the same...
So are you ok with printing the error message on a separate line? Adding just one newline. Not 100% clear to me from the above, sorry.
I tested this PR heavily (especially compared to how small of a code change it is...) and NOT having the error message trailing a 5-10 lines-long command made a massive difference. It's quite painful to find before this PR.
I don't mind the code style and the number of logging statements, the terminal output and "user experience" is really the purpose of this.
|
@marc-hb I merged a variation of this PR in the linked pr. Let me know if that doesn't address your issue |
|
That should do it, thx! |
As discussed in #3948 and #3992, logging commands failing in a sandbox without ever mentioning that a sandbox was in use is misleading and very time-consuming; notably because paths look real but they are not.
To remove this confusion and cost, simply add one short line mentioning that a sandbox was involved when the failure happened + recommend to re-run with --debug to display bind mounts and other important information.
Also separate the command and error message on different lines for better readability and re-usability.
Just for the record: before commit 7e7a3c7 ("Don't log sandbox for every command"),
run.pywas logging sandbox commands every time which was too verbose and unreadable. That commit said "... but still log the full sandbox if a command fails" and it did that do in__init__.py- but not always inrun.py. After that commit, the sandbox was logged byrun.pyonly in --debug mode and became completely invisible otherwise.