1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-21 18:41:03 +00:00

Merge pull request #1451 from kimheino/master

gluster: "volume status all detail" command fails randomly. Sleep and retry.
This commit is contained in:
Kenyon Ralph 2024-09-10 10:53:41 -07:00 committed by GitHub
commit a0821117ad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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: