resource-agents/SOURCES/bz1845574-azure-events-1-ha...

71 lines
2.7 KiB
Diff

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