Blame SOURCES/bz1839776-fence_aws-catch-connectionerror.patch

91f48e
From be20615859c518b3161b08ee63f5da5213eba91d Mon Sep 17 00:00:00 2001
91f48e
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
91f48e
Date: Mon, 25 May 2020 14:03:53 +0200
91f48e
Subject: [PATCH 1/2] fence_aws: catch ConnectionError and suppress traceback
91f48e
 for caught exceptions
91f48e
91f48e
---
91f48e
 agents/aws/fence_aws.py | 10 ++++++----
91f48e
 1 file changed, 6 insertions(+), 4 deletions(-)
91f48e
91f48e
diff --git a/agents/aws/fence_aws.py b/agents/aws/fence_aws.py
91f48e
index 17c2fedb..191f5de1 100644
91f48e
--- a/agents/aws/fence_aws.py
91f48e
+++ b/agents/aws/fence_aws.py
91f48e
@@ -9,14 +9,14 @@
91f48e
 from fencing import fail, fail_usage, run_delay, EC_STATUS, SyslogLibHandler
91f48e
 
91f48e
 import boto3
91f48e
-from botocore.exceptions import ClientError, EndpointConnectionError, NoRegionError
91f48e
+from botocore.exceptions import ConnectionError, ClientError, EndpointConnectionError, NoRegionError
91f48e
 
91f48e
 logger = logging.getLogger("fence_aws")
91f48e
 logger.propagate = False
91f48e
 logger.setLevel(logging.INFO)
91f48e
 logger.addHandler(SyslogLibHandler())
91f48e
 logging.getLogger('botocore.vendored').propagate = False
91f48e
-	
91f48e
+
91f48e
 def get_instance_id():
91f48e
 	try:
91f48e
 		r = requests.get('http://169.254.169.254/latest/meta-data/instance-id')
91f48e
@@ -38,6 +38,8 @@ def get_nodes_list(conn, options):
91f48e
 		fail_usage("Failed: Incorrect Access Key or Secret Key.")
91f48e
 	except EndpointConnectionError:
91f48e
 		fail_usage("Failed: Incorrect Region.")
91f48e
+	except ConnectionError as e:
91f48e
+		fail_usage("Failed: Unable to connect to AWS: " + str(e))
91f48e
 	except Exception as e:
91f48e
 		logger.error("Failed to get node list: %s", e)
91f48e
 	logger.debug("Monitor operation OK: %s",result)
91f48e
@@ -169,7 +171,7 @@ def main():
91f48e
 	
91f48e
 	if options["--boto3_debug"] != "on":
91f48e
 		boto3.set_stream_logger('boto3',logging.INFO)
91f48e
-		boto3.set_stream_logger('botocore',logging.INFO)
91f48e
+		boto3.set_stream_logger('botocore',logging.CRITICAL)
91f48e
 		logging.getLogger('botocore').propagate = False
91f48e
 		logging.getLogger('boto3').propagate = False
91f48e
 	else:
91f48e
@@ -197,4 +199,4 @@ def main():
91f48e
 	sys.exit(result)
91f48e
 
91f48e
 if __name__ == "__main__":
91f48e
-	main()
91f48e
\ No newline at end of file
91f48e
+	main()
91f48e
91f48e
From 50772024cffa60d05938d328bbd5cffd930f6b42 Mon Sep 17 00:00:00 2001
91f48e
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
91f48e
Date: Mon, 25 May 2020 14:07:14 +0200
91f48e
Subject: [PATCH 2/2] fence_aws: improve boto3_debug boolean handling
91f48e
91f48e
---
91f48e
 agents/aws/fence_aws.py           | 4 ++--
91f48e
 2 files changed, 3 insertions(+), 3 deletions(-)
91f48e
91f48e
diff --git a/agents/aws/fence_aws.py b/agents/aws/fence_aws.py
91f48e
index 191f5de1..483a2991 100644
91f48e
--- a/agents/aws/fence_aws.py
91f48e
+++ b/agents/aws/fence_aws.py
91f48e
@@ -132,6 +132,7 @@ def define_new_opts():
91f48e
 		"help" : "-b, --boto3_debug=[option]      Boto3 and Botocore library debug logging",
91f48e
 		"shortdesc": "Boto Lib debug",
91f48e
 		"required": "0",
91f48e
+		"default": "False",
91f48e
 		"order": 5
91f48e
 	}
91f48e
 
91f48e
@@ -146,7 +147,6 @@ def main():
91f48e
 	define_new_opts()
91f48e
 
91f48e
 	all_opt["power_timeout"]["default"] = "60"
91f48e
-	all_opt["boto3_debug"]["default"] = "off"
91f48e
 
91f48e
 	options = check_input(device_opt, process_input(device_opt))
91f48e
 
91f48e
@@ -169,7 +169,7 @@ def main():
91f48e
 		lh.setFormatter(lhf)
91f48e
 		logger.setLevel(logging.DEBUG)
91f48e
 	
91f48e
-	if options["--boto3_debug"] != "on":
91f48e
+	if options["--boto3_debug"].lower() not in ["1", "yes", "on", "true"]:
91f48e
 		boto3.set_stream_logger('boto3',logging.INFO)
91f48e
 		boto3.set_stream_logger('botocore',logging.CRITICAL)
91f48e
 		logging.getLogger('botocore').propagate = False