fix(Base): log the output of successful commands as debug. - #951
Open
lengau wants to merge 5 commits into
Open
Conversation
…250) Adds two tests for subprocess output visibility: 1. test_execute_run_logs_output_at_debug [FAILS] — _execute_run() captures stdout from every command via capture_output=True, but never logs it. Operators using debug/trace logging see nothing from in-container commands (apt-get, systemctl, etc.) even when they run successfully. 2. test_execute_run_output_included_in_error_details [PASSES] — verifies that the 'output shown on error' half of #250 already works: when a subprocess fails, its stdout is captured and included in the BaseConfigurationError details via details_from_called_process_error(). The fix for the failing test is to log proc.stdout at debug level inside _execute_run() after a successful run. Fixes: #250 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
_execute_run() captures output via capture_output=True but previously discarded it on success. Now logs proc.stdout and proc.stderr at debug level so operators running with -v or debug logging can see what in- container commands (apt-get, systemctl, snap, etc.) printed without needing to reproduce a full failure. Fixes: #250 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
lengau
marked this pull request as ready for review
April 22, 2026 05:26
Contributor
|
how noisy is this on a regular run? |
Member
|
I like the change, but I second Tiago's question -- if it's particularly noisy, I might suggest moving this to trace instead. |
Collaborator
Author
bepri
approved these changes
May 4, 2026
mr-cal
reviewed
May 4, 2026
mr-cal
left a comment
Contributor
There was a problem hiding this comment.
This will be a very helpful improvement, just being critical on readability.
Co-authored-by: Callahan Kovacs <callahan.kovacs@canonical.com> Signed-off-by: Alex Lowe <alex.lowe@canonical.com>
Co-authored-by: Callahan Kovacs <callahan.kovacs@canonical.com> Signed-off-by: Alex Lowe <alex.lowe@canonical.com>
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.
Reproducer for #250
craft-providers runs many commands inside instances (
apt-get,systemctl,snap, etc.) but never logs their output, even when running with debug/trace logging. Operators diagnosing problems have to reproduce a full failure to see what a command printed.Failing test
test_execute_run_logs_output_at_debug— shows that_execute_run()captures stdout viacapture_output=Truebut never writes it to the logger. After the command completes successfully, the output is simply discarded.Bonus passing test
test_execute_run_output_included_in_error_details— verifies that the other half of #250 ("output not shown on error") already works: when a subprocess fails, its stdout is preserved on theCalledProcessErrorand included in theBaseConfigurationErrordetails viadetails_from_called_process_error(). This serves as a regression guard.Fix
In
Base._execute_run(), afterexecutor.execute_run()returns successfully, logproc.stdoutandproc.stderratlogger.debuglevel (guarded by a truthiness check so empty output is not logged).Closes #250