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

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