Bug 1289776 - mockchain discards stdout & stderr from mock on failure
mockchain discards stdout & stderr from mock on failure
Product: Fedora
Classification: Fedora
Component: mock (Show other bugs)
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Clark Williams
Fedora Extras Quality Assurance
Depends On:
  Show dependency treegraph
Reported: 2015-12-08 18:07 EST by Nick Bartos
Modified: 2017-08-08 08:30 EDT (History)
7 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2017-08-08 08:30:29 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
Preserve stdout and stderr of mock (2.28 KB, patch)
2015-12-09 13:14 EST, Nick Bartos
no flags Details | Diff

  None (edit)
Description Nick Bartos 2015-12-08 18:07:28 EST
Description of problem:

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:

Actual results:

Expected results:

Additional info:
Comment 1 Nick Bartos 2015-12-08 18:13:06 EST
Sorry I accidentally hit enter before filling out the report completely, and it appears I can't edit the description of the problem.

The stderr and stdout from mockchain's do_build function is discarded when mock returns failure, which is infuriating when there is no other failure messages logged by mock itself.  The stderr and stdout of mock should be either written to log files in the mock output directory, or sent to mockchain's logger.
Comment 2 Nick Bartos 2015-12-09 13:14 EST
Created attachment 1104065 [details]
Preserve stdout and stderr of mock

After looking at master, I see there is some attempt to propagate stderr of mock up to stderr of mockchain.  However the approach has a couple of drawbacks:

1.  If --log is used for mockchain, Mock's stderr is not sent to it.
2.  Mock's stdout is not preserved, sometimes stdout can have useful debugging info.
3.  Mock's stderr and stdout is not preserved on apparent success.  If the command returns success, but something else is wrong, it would be nice to have that debug info preserved.

The patch I've attached makes stderr.log and stdout.log files which are saved along side the other individual package log files.  I think this approach is the most consistent with existing logging methods, and also preserves the maximum amount of information for debugging.
Comment 3 Miroslav Suchý 2015-12-21 18:52:41 EST
I fail to see problem here. The stdout and stderr is put together and put into resultdir/<name of package>/ and named build.log root.log and state.log, which are far better for debugging what happen during build time.

Can you better describe the reproducer of your problem?
Comment 4 Nick Bartos 2015-12-22 11:41:52 EST
To reproduce the problem which brought me here, you can install the latest version of mock that is available in ubuntu 15.10 (1.1.33-1), and set config_opts['chroot_setup_cmd'] to something that will _not_ install useradd.  Then you will see that all builds fail, but there is no error anywhere to be found on stdout/stderr of mockchain, or in any one of the output files.  This is because the error is generated by the mock program itself, and is placed on it's stderr, which is discarded.

After looking at master, I see there is one enhancement:

That will propagate up the error I mentioned above from mock's stderr to mockchain's stderr.  While it does fix one problem, it is not ideal, as stdout is completely discarded (and unfortunately some debugging information on a failure can be found on stdout sometimes), and stderr is discarded in the case of mock returning 0 (which would discard any non-fatal warnings that could be useful in debugging).

In master you can see the output of mock's communicate is stored in out and err, and returned from do_build:
out, err = cmd.communicate()

Then look at the one call for do_build:

You will see that out and err are never used in that function (pylint will warn about it too).

Mock does not write it's own stdout and stderr to resultdir, and mockchain does not currently do it either.  From my perspective, it makes a lot of sense to have mockchain to be writing them to a file.  Modifying mock to write it's own stdout and stderr to the resultdir doesn't seem like a good idea, as that would potentially break other things using mock.
Comment 5 Jan Kurik 2016-02-24 09:07:12 EST
This bug appears to have been reported against 'rawhide' during the Fedora 24 development cycle.
Changing version to '24'.

More information and reason for this action is here:
Comment 6 Fedora End Of Life 2017-07-25 15:37:04 EDT
This message is a reminder that Fedora 24 is nearing its end of life.
Approximately 2 (two) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 24. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '24'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version'
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not
able to fix it before Fedora 24 is end of life. If you would still like
to see this bug fixed and are able to reproduce it against a later version
of Fedora, you are encouraged  change the 'version' to a later Fedora
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.
Comment 7 Fedora End Of Life 2017-08-08 08:30:29 EDT
Fedora 24 changed to end-of-life (EOL) status on 2017-08-08. Fedora 24 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this

Thank you for reporting this bug and we are sorry it could not be fixed.

Note You need to log in before you can comment on or make changes to this bug.