[sos-devel] [sosreport] Wrong exit code on fail

Denis Egorenko egorenko.den at gmail.com
Fri Jan 24 06:55:04 UTC 2020


Hi Bryn,

Thanks for responding. I've already implemented exactly same fix as you
proposed for my env and now it's working fine.

I hope sosreport team will take care to deliver that fix before next
release.

Regards,
Denis,

чт, 23 янв. 2020 г. в 17:49, Bryn M. Reeves <bmr at redhat.com>:

> On Wed, Dec 11, 2019 at 01:15:37PM +0400, Denis Egorenko wrote:
> > No changes will be made to system configuration.
> >
> >
> >  Setting up archive ...
> >
> >  No space left on device while setting up archive
> >
> > :~# echo $?
> > 0
>
> Looks like this has regressed (we've had a few problems with exit
> status propagation down the years). The fix for the exit status
> itself is fairly simple:
>
> diff --git a/sos/sosreport.py b/sos/sosreport.py
> index c13142c7..0a4c304f 100644
> --- a/sos/sosreport.py
> +++ b/sos/sosreport.py
> @@ -1371,9 +1371,9 @@ class SoSReport(object):
>              self.ui_log.error("\nExiting on user cancel")
>              self._cleanup()
>              self._exit(130)
> -        except (SystemExit):
> +        except (SystemExit) as e:
>              self._cleanup()
> -            self._exit(0)
> +            sys.exit(e.code)
>
>          self._exit(1)
>
> The problem happens because whatever status was set by the error
> that first called self._exit() is overwritten by the call that
> follows the _cleanup() handler with 0. The fix simply re-uses
> the original exit status passed via SystemExit.code.
>
> This may be enough for your use case since you just care about
> the overall status but looking at current master there's a bit
> more work needed in this area. Right now, for each plugin that
> is running at the time of failure you'll see a bunch of log
> spew like this:
>
> [plugin:dnf] collecting tail of '/var/log/dnf.librepo.log' due to size
> limit
> Traceback (most recent call last):
>   File "/usr/lib64/python2.7/logging/__init__.py", line 892, in emit
>     self.flush()
>   File "/usr/lib64/python2.7/logging/__init__.py", line 852, in flush
>     self.stream.flush()
> IOError: [Errno 28] No space left on device
> Logged from file __init__.py, line 432
>
> It's cosmetic but obviously not ideal: addressing this will be
> a bit more complicated but should be something we can get to
> before the next release.
>
> Regards,
> Bryn.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/sos-devel/attachments/20200124/5156c732/attachment.htm>


More information about the sos-devel mailing list