From bf65da0c58adcd14710492d083666a42981a9146 Mon Sep 17 00:00:00 2001 From: Cyril Levis Date: Wed, 30 Nov 2022 09:49:51 +0100 Subject: [PATCH] fix: deadlock storcli inventory When there is a lot of data return by storcli due to a lot of disk, the inventory was in deadlock Its a known problem, see: https://docs.python.org/3/library/subprocess.html#subprocess.Popen.wait --- netbox_agent/raid/storcli.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/netbox_agent/raid/storcli.py b/netbox_agent/raid/storcli.py index c80380c..8eacae6 100644 --- a/netbox_agent/raid/storcli.py +++ b/netbox_agent/raid/storcli.py @@ -21,14 +21,17 @@ def storecli(sub_command): stdout=subprocess.PIPE, stderr=subprocess.STDOUT ) - p.wait() - stdout = p.stdout.read().decode("utf-8") - if p.returncode != 0: + + stdout, stderr = p.communicate() + if stderr: mesg = "Failed to execute command '{}':\n{}".format( " ".join(command), stdout ) raise StorcliControllerError(mesg) + + stdout = stdout.decode("utf-8") data = json.loads(stdout) + controllers = dict([ ( c['Command Status']['Controller'],