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

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