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