Skip to contentSkip to conversation

main - lvmdbusd: Replace assert with exception

PATCH Tony Asleson 1 participant 1 message Mar 10, 2023

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=3d854b39bd8c3740eae087c4d46e5f685b368f5e
Commit:        3d854b39bd8c3740eae087c4d46e5f685b368f5e
Parent:        e79c6feb080f30fc4bb4adbfd69c41ac90b6cde3
Author:        Tony Asleson <[email protected]>
AuthorDate:    Thu Mar 9 11:19:29 2023 -0600
Committer:     Tony Asleson <[email protected]>
CommitterDate: Fri Mar 10 12:51:53 2023 -0600

lvmdbusd: Replace assert with exception

Instead of using an assert we will raise an LvmBug exception

---
 daemons/lvmdbusd/cmdhandler.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
daemons/lvmdbusd/cmdhandler.py +3 -1
index 8bc741dc6..cf2a70875 100644
@@ -637,7 +637,9 @@ def lvm_full_report_json():
 	rc, out, err = call(cmd)
 	# When we have an exported vg the exit code of lvs or fullreport will be 5
 	if rc == 0 or rc == 5:
-		assert(type(out) == dict)
+		if type(out) != dict:
+			raise LvmBug("lvm likely returned invalid JSON, lvm exit code = %d, output = %s, err= %s" %
+						 (rc, str(out), str(err)))
 		return out
 	raise LvmBug("'fullreport' exited with code '%d'" % rc)