All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tony Asleson <tasleson@sourceware.org>
To: lvm-devel@redhat.com
Subject: main - lvmdbusd: Wrap json.load in try/except
Date: Thu, 17 Jun 2021 14:17:02 +0000 (GMT)	[thread overview]
Message-ID: <20210617141702.87579385040A@sourceware.org> (raw)

Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f7730406254f023216d0727c82d46de82c124c92
Commit:        f7730406254f023216d0727c82d46de82c124c92
Parent:        c474f174cc8b0e855f984bf211f5416b42c644a1
Author:        Tony Asleson <tasleson@redhat.com>
AuthorDate:    Mon Jun 14 22:04:09 2021 -0500
Committer:     Tony Asleson <tasleson@redhat.com>
CommitterDate: Thu Jun 17 09:14:29 2021 -0500

lvmdbusd: Wrap json.load in try/except

In testing where we inject large amounts of additional output in stderr
we can occassionally get truncated stdout from lvm.  Catching and dumping
the json for debug before we re-raise the exception.  As this doesn't
happen without the error injecting wrapper around lvm, the error seems to
be with the wrapper.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
---
 daemons/lvmdbusd/cmdhandler.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/daemons/lvmdbusd/cmdhandler.py b/daemons/lvmdbusd/cmdhandler.py
index 91f69abcf..b88bd9896 100644
--- a/daemons/lvmdbusd/cmdhandler.py
+++ b/daemons/lvmdbusd/cmdhandler.py
@@ -627,7 +627,13 @@ def lvm_full_report_json():
 			assert(type(out) == dict)
 			return out
 		else:
-			return json.loads(out)
+			try:
+				return json.loads(out)
+			except json.decoder.JSONDecodeError as joe:
+				log_error("JSONDecodeError %s, \n JSON=\n%s\n" %
+							(str(joe), out))
+				raise joe
+
 	return None
 
 



                 reply	other threads:[~2021-06-17 14:17 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210617141702.87579385040A@sourceware.org \
    --to=tasleson@sourceware.org \
    --cc=lvm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.