Blame SOURCES/bz1832289-fence_aws-improve-catch-connectionerror.patch

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