Blame SOURCES/bz1653700-3-fence_scsi-watchdog-fix-retry-failing-on-first-try.patch

7c014a
From 418b3a36c8a7de0e984a0cd4707f2b90f279c4ce Mon Sep 17 00:00:00 2001
7c014a
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
7c014a
Date: Thu, 13 Jun 2019 11:29:25 +0200
7c014a
Subject: [PATCH] fence_scsi watchdog: dont exit when command fails using retry
7c014a
 parameter
7c014a
7c014a
---
7c014a
 lib/fencing.py.py | 7 ++++---
7c014a
 1 file changed, 4 insertions(+), 3 deletions(-)
7c014a
7c014a
diff --git a/lib/fencing.py.py b/lib/fencing.py.py
7c014a
index 8cd0a813..6f2526a9 100644
7c014a
--- a/lib/fencing.py.py
7c014a
+++ b/lib/fencing.py.py
7c014a
@@ -530,7 +530,7 @@ def fail_usage(message="", stop=True):
7c014a
 		logging.error("Please use '-h' for usage\n")
7c014a
 		sys.exit(EC_GENERIC_ERROR)
7c014a
 
7c014a
-def fail(error_code):
7c014a
+def fail(error_code, stop=True):
7c014a
 	message = {
7c014a
 		EC_LOGIN_DENIED : "Unable to connect/login to fencing device",
7c014a
 		EC_CONNECTION_LOST : "Connection lost",
7c014a
@@ -546,7 +546,8 @@ def fail(error_code):
7c014a
 
7c014a
 	}[error_code] + "\n"
7c014a
 	logging.error("%s\n", message)
7c014a
-	sys.exit(EC_GENERIC_ERROR)
7c014a
+	if stop:
7c014a
+		sys.exit(EC_GENERIC_ERROR)
7c014a
 
7c014a
 def usage(avail_opt):
7c014a
 	print("Usage:")
7c014a
@@ -1009,7 +1010,7 @@ def run_command(options, command, timeout=None, env=None, log_command=None):
7c014a
 	thread.join(timeout)
7c014a
 	if thread.is_alive():
7c014a
 		process.kill()
7c014a
-		fail(EC_TIMED_OUT)
7c014a
+		fail(EC_TIMED_OUT, stop=(int(options.get("retry", 0)) < 1))
7c014a
 
7c014a
 	status = process.wait()
7c014a