From acdd7b432f63b3ed788370f2906099d18d4d8cb8 Mon Sep 17 00:00:00 2001 From: "Kim B. Heino" Date: Tue, 10 Sep 2024 14:05:03 +0300 Subject: [PATCH] gluster: "volume status all detail" command fails randomly. Sleep and retry. --- plugins/disk/gluster | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/plugins/disk/gluster b/plugins/disk/gluster index 8f452ebe..5a4bc18b 100755 --- a/plugins/disk/gluster +++ b/plugins/disk/gluster @@ -36,17 +36,23 @@ GPLv2 import os import subprocess import sys +import time import xml.etree.ElementTree def run_command(command): """Run gluster command and return it's output as etree.""" - try: - text = subprocess.run(['gluster', '--mode=script', '--xml'] + command, - check=False, stdout=subprocess.PIPE, - stderr=subprocess.PIPE, encoding='utf-8').stdout - except FileNotFoundError: - return None + for _dummy_retry in range(3): + try: + text = subprocess.run(['gluster', '--mode=script', '--xml'] + + command, check=False, stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + encoding='utf-8').stdout + except FileNotFoundError: + return None + if text.count('\n') > 10: + break + time.sleep(2) # Sleep and retry try: return xml.etree.ElementTree.fromstring(text) except xml.etree.ElementTree.ParseError: