[Libguestfs] [libnbd PATCH v2] nbdsh: Catch nbd.Error from -c arguments

Daniel P. Berrangé berrange at redhat.com
Tue Sep 22 16:18:03 UTC 2020


On Tue, Sep 22, 2020 at 11:15:39AM -0500, Eric Blake wrote:
> When using nbdsh for scripting, it is convenient to let nbdsh fail
> with status 1 when encountering an API failure.  However, doing so by
> letting the nbd.Error exception leak all the way causes ABRT (at least
> on Fedora 32 with abrt-python3-handler installed) to assume the
> program crashed from a programming error, and needlessly complicates
> clients to have to add try: blocks.  Better is if nbdsh itself handles
> the problem, and only prints a stack trace when debugging is in
> effect, but otherwise just prints the error message.  In this way, the
> user is not presented with a wall of python stack trace, and ABRT does
> not think that the exception was unhandled.
> 
> See https://github.com/libguestfs/nbdkit/commit/e13048fd9 for an
> example of client cleanup made more verbose if we don't patch libnbd.
> ---
> 
> On IRC, we decided that printing the stack trace can be useful when
> debugging (if -c triggers calls through some deeply-nested python
> code), but generally gets in the way for default behavior.
> 
>  python/nbdsh.py  | 20 ++++++++++++++++----
>  sh/test-error.sh | 23 ++++++++++++++++++++++-
>  2 files changed, 38 insertions(+), 5 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange at redhat.com>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|




More information about the Libguestfs mailing list