|
|
02ddf4 |
From 194909ff08cfe75cd5da9f704d8ed4cc9ab40341 Mon Sep 17 00:00:00 2001
|
|
|
02ddf4 |
From: Gustavo Figueira <gfigueira@suse.com>
|
|
|
02ddf4 |
Date: Tue, 19 May 2020 10:58:34 +0200
|
|
|
02ddf4 |
Subject: [PATCH 1/2] azure-events: handle exceptions in urlopen The locking in
|
|
|
02ddf4 |
azure-events does not correctly handle some failures.
|
|
|
02ddf4 |
|
|
|
02ddf4 |
If the metadata server is not recheable or has an error
|
|
|
02ddf4 |
handling the request, attr_globalPullState will never go
|
|
|
02ddf4 |
back to IDLE unless the administrator manually changes it.
|
|
|
02ddf4 |
|
|
|
02ddf4 |
> azure-events: ERROR: [Errno 104] Connection reset by peer
|
|
|
02ddf4 |
> lrmd[2734]: notice: rsc_azure-events_monitor_10000:113088:stderr [ ocf-exit-reason:[Errno 104] Connection reset by peer ]
|
|
|
02ddf4 |
---
|
|
|
02ddf4 |
heartbeat/azure-events.in | 16 +++++++++++++---
|
|
|
02ddf4 |
1 file changed, 13 insertions(+), 3 deletions(-)
|
|
|
02ddf4 |
|
|
|
02ddf4 |
diff --git a/heartbeat/azure-events.in b/heartbeat/azure-events.in
|
|
|
02ddf4 |
index 8709d97e3..bd812f4b2 100644
|
|
|
02ddf4 |
--- a/heartbeat/azure-events.in
|
|
|
02ddf4 |
+++ b/heartbeat/azure-events.in
|
|
|
02ddf4 |
@@ -82,9 +82,19 @@ class azHelper:
|
|
|
02ddf4 |
req = urllib2.Request(url, postData)
|
|
|
02ddf4 |
req.add_header("Metadata", "true")
|
|
|
02ddf4 |
req.add_header("User-Agent", USER_AGENT)
|
|
|
02ddf4 |
- resp = urllib2.urlopen(req)
|
|
|
02ddf4 |
- data = resp.read()
|
|
|
02ddf4 |
- ocf.logger.debug("_sendMetadataRequest: response = %s" % data)
|
|
|
02ddf4 |
+ try:
|
|
|
02ddf4 |
+ resp = urllib2.urlopen(req)
|
|
|
02ddf4 |
+ except URLError as e:
|
|
|
02ddf4 |
+ if hasattr(e, 'reason'):
|
|
|
02ddf4 |
+ print('We failed to reach a server. Reason: '), e.reason
|
|
|
02ddf4 |
+ clusterHelper.setAttr(attr_globalPullState, "IDLE")
|
|
|
02ddf4 |
+ elif hasattr(e, 'code'):
|
|
|
02ddf4 |
+ print('The server couldn\'t fulfill the request. Error code: '), e.code
|
|
|
02ddf4 |
+ clusterHelper.setAttr(attr_globalPullState, "IDLE")
|
|
|
02ddf4 |
+ else:
|
|
|
02ddf4 |
+ data = resp.read()
|
|
|
02ddf4 |
+ ocf.logger.debug("_sendMetadataRequest: response = %s" % data)
|
|
|
02ddf4 |
+
|
|
|
02ddf4 |
if data:
|
|
|
02ddf4 |
data = json.loads(data)
|
|
|
02ddf4 |
|
|
|
02ddf4 |
|
|
|
02ddf4 |
From c4071ec4a82fcb831f170f341e0790633e4b904f Mon Sep 17 00:00:00 2001
|
|
|
02ddf4 |
From: Gustavo Figueira <gfigueira@suse.com>
|
|
|
02ddf4 |
Date: Tue, 19 May 2020 12:53:22 +0200
|
|
|
02ddf4 |
Subject: [PATCH 2/2] azure-events: use ocf.logger.warning instead of print
|
|
|
02ddf4 |
|
|
|
02ddf4 |
---
|
|
|
02ddf4 |
heartbeat/azure-events.in | 4 ++--
|
|
|
02ddf4 |
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
|
02ddf4 |
|
|
|
02ddf4 |
diff --git a/heartbeat/azure-events.in b/heartbeat/azure-events.in
|
|
|
02ddf4 |
index bd812f4b2..a48a86309 100644
|
|
|
02ddf4 |
--- a/heartbeat/azure-events.in
|
|
|
02ddf4 |
+++ b/heartbeat/azure-events.in
|
|
|
02ddf4 |
@@ -86,10 +86,10 @@ class azHelper:
|
|
|
02ddf4 |
resp = urllib2.urlopen(req)
|
|
|
02ddf4 |
except URLError as e:
|
|
|
02ddf4 |
if hasattr(e, 'reason'):
|
|
|
02ddf4 |
- print('We failed to reach a server. Reason: '), e.reason
|
|
|
02ddf4 |
+ ocf.logger.warning("Failed to reach the server: %s" % e.reason)
|
|
|
02ddf4 |
clusterHelper.setAttr(attr_globalPullState, "IDLE")
|
|
|
02ddf4 |
elif hasattr(e, 'code'):
|
|
|
02ddf4 |
- print('The server couldn\'t fulfill the request. Error code: '), e.code
|
|
|
02ddf4 |
+ ocf.logger.warning("The server couldn\'t fulfill the request. Error code: %s" % e.code)
|
|
|
02ddf4 |
clusterHelper.setAttr(attr_globalPullState, "IDLE")
|
|
|
02ddf4 |
else:
|
|
|
02ddf4 |
data = resp.read()
|