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

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