diff --git a/SOURCES/bz1819965-4-azure-events-import-urlerror-encode-postdata.patch b/SOURCES/bz1819965-4-azure-events-import-urlerror-encode-postdata.patch deleted file mode 100644 index 2e95152..0000000 --- a/SOURCES/bz1819965-4-azure-events-import-urlerror-encode-postdata.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 14765fca34efb80598463aba49a48758ffca598c Mon Sep 17 00:00:00 2001 -From: Oyvind Albrigtsen -Date: Mon, 27 Jul 2020 10:09:43 +0200 -Subject: [PATCH] azure-events: import URLError in Python 3+ and encode - postData when necessary - ---- - heartbeat/azure-events.in | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/heartbeat/azure-events.in b/heartbeat/azure-events.in -index d4a166d9f..4eed376fb 100644 ---- a/heartbeat/azure-events.in -+++ b/heartbeat/azure-events.in -@@ -15,6 +15,7 @@ try: - import urllib2 - except ImportError: - import urllib.request as urllib2 -+ from urllib.error import URLError - import socket - from collections import defaultdict - -@@ -79,6 +80,9 @@ class azHelper: - ocf.logger.debug("_sendMetadataRequest: begin; endpoint = %s, postData = %s" % (endpoint, postData)) - ocf.logger.debug("_sendMetadataRequest: url = %s" % url) - -+ if postData and type(postData) != bytes: -+ postData = postData.encode() -+ - req = urllib2.Request(url, postData) - req.add_header("Metadata", "true") - req.add_header("User-Agent", USER_AGENT) diff --git a/SOURCES/bz1845574-azure-events-1-handle-exceptions-in-urlopen.patch b/SOURCES/bz1845574-azure-events-1-handle-exceptions-in-urlopen.patch new file mode 100644 index 0000000..fa194c9 --- /dev/null +++ b/SOURCES/bz1845574-azure-events-1-handle-exceptions-in-urlopen.patch @@ -0,0 +1,70 @@ +From 194909ff08cfe75cd5da9f704d8ed4cc9ab40341 Mon Sep 17 00:00:00 2001 +From: Gustavo Figueira +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 +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() diff --git a/SOURCES/bz1845574-azure-events-2-import-urlerror-encode-postdata.patch b/SOURCES/bz1845574-azure-events-2-import-urlerror-encode-postdata.patch new file mode 100644 index 0000000..7795e78 --- /dev/null +++ b/SOURCES/bz1845574-azure-events-2-import-urlerror-encode-postdata.patch @@ -0,0 +1,68 @@ +From f2bf1d8a07ea810099b03469883cb7f485ab9ac1 Mon Sep 17 00:00:00 2001 +From: Oyvind Albrigtsen +Date: Mon, 27 Jul 2020 10:09:43 +0200 +Subject: [PATCH 1/2] azure-events: import URLError and encode postData when + necessary + +--- + heartbeat/azure-events.in | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/heartbeat/azure-events.in b/heartbeat/azure-events.in +index d4a166d9f..a7f359468 100644 +--- a/heartbeat/azure-events.in ++++ b/heartbeat/azure-events.in +@@ -13,8 +13,10 @@ import subprocess + import json + try: + import urllib2 ++ from urllib2 import URLError + except ImportError: + import urllib.request as urllib2 ++ from urllib.error import URLError + import socket + from collections import defaultdict + +@@ -76,9 +78,13 @@ class azHelper: + Send a request to Azure's Azure Metadata Service API + """ + url = "%s/%s?api-version=%s" % (azHelper.metadata_host, endpoint, azHelper.api_version) ++ data = "" + ocf.logger.debug("_sendMetadataRequest: begin; endpoint = %s, postData = %s" % (endpoint, postData)) + ocf.logger.debug("_sendMetadataRequest: url = %s" % url) + ++ if postData and type(postData) != bytes: ++ postData = postData.encode() ++ + req = urllib2.Request(url, postData) + req.add_header("Metadata", "true") + req.add_header("User-Agent", USER_AGENT) + +From 1ab5d71bff95eb271f1e1bbc401961dc313219d9 Mon Sep 17 00:00:00 2001 +From: Oyvind Albrigtsen +Date: Wed, 29 Jul 2020 21:25:43 +0200 +Subject: [PATCH 2/2] azure-events: report error if jsondata not received + +--- + heartbeat/azure-events.in | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +diff --git a/heartbeat/azure-events.in b/heartbeat/azure-events.in +index a7f359468..3a24d6358 100644 +--- a/heartbeat/azure-events.in ++++ b/heartbeat/azure-events.in +@@ -117,8 +117,12 @@ class azHelper: + jsondata = azHelper._sendMetadataRequest(azHelper.instance_api) + ocf.logger.debug("getInstanceInfo: json = %s" % jsondata) + +- ocf.logger.debug("getInstanceInfo: finished, returning {}".format(jsondata["compute"])) +- return attrDict(jsondata["compute"]) ++ if jsondata: ++ ocf.logger.debug("getInstanceInfo: finished, returning {}".format(jsondata["compute"])) ++ return attrDict(jsondata["compute"]) ++ else: ++ ocf.ocf_exit_reason("getInstanceInfo: Unable to get instance info") ++ sys.exit(ocf.OCF_ERR_GENERIC) + + @staticmethod + def pullScheduledEvents(): diff --git a/SOURCES/bz1845574-azure-events-handle-exceptions-in-urlopen.patch b/SOURCES/bz1845574-azure-events-handle-exceptions-in-urlopen.patch deleted file mode 100644 index fa194c9..0000000 --- a/SOURCES/bz1845574-azure-events-handle-exceptions-in-urlopen.patch +++ /dev/null @@ -1,70 +0,0 @@ -From 194909ff08cfe75cd5da9f704d8ed4cc9ab40341 Mon Sep 17 00:00:00 2001 -From: Gustavo Figueira -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 -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() diff --git a/SPECS/resource-agents.spec b/SPECS/resource-agents.spec index 4e59e7b..563ea7a 100644 --- a/SPECS/resource-agents.spec +++ b/SPECS/resource-agents.spec @@ -70,7 +70,7 @@ Name: resource-agents Summary: Open Source HA Reusable Cluster Resource Scripts Version: 4.1.1 -Release: 64%{?rcver:%{rcver}}%{?numcomm:.%{numcomm}}%{?alphatag:.%{alphatag}}%{?dirty:.%{dirty}}%{?dist} +Release: 65%{?rcver:%{rcver}}%{?numcomm:.%{numcomm}}%{?alphatag:.%{alphatag}}%{?dirty:.%{dirty}}%{?dist} License: GPLv2+ and LGPLv2+ URL: https://github.com/ClusterLabs/resource-agents %if 0%{?fedora} || 0%{?centos_version} || 0%{?rhel} @@ -223,7 +223,7 @@ Patch131: bz1633251-gcp-pd-move-5-bundle.patch Patch132: bz1839721-podman-force-rm-container-if-rm-fails.patch Patch133: bz1820523-exportfs-2-fix-monitor-action.patch Patch134: bz1843999-aliyun-vpc-move-ip-log-output-when-failing.patch -Patch135: bz1845574-azure-events-handle-exceptions-in-urlopen.patch +Patch135: bz1845574-azure-events-1-handle-exceptions-in-urlopen.patch Patch136: bz1845581-nfsserver-dont-log-error-message-file-doesnt-exist.patch Patch137: bz1845583-exportfs-1-describe-clientspec-format-in-metadata.patch Patch138: bz1845583-exportfs-2-fix-typo.patch @@ -232,7 +232,7 @@ Patch140: bz1836186-pgsql-support-Pacemaker-v2.03-output.patch Patch141: bz1819965-3-azure-events-decode-when-type-not-str.patch Patch142: bz1818997-nfsserver-2-stop-nfsdcld-if-present.patch Patch143: bz1818997-3-nfsserver-nfsnotify-fix-selinux-label-issue.patch -Patch144: bz1819965-4-azure-events-import-urlerror-encode-postdata.patch +Patch144: bz1845574-azure-events-2-import-urlerror-encode-postdata.patch # bundle patches Patch1000: 7-gcp-bundled.patch @@ -1089,6 +1089,11 @@ ccs_update_schema > /dev/null 2>&1 ||: %endif %changelog +* Thu Jul 30 2020 Oyvind Albrigtsen - 4.1.1-65 +- azure-events: handle exceptions in urlopen + + Resolves: rhbz#1845574 + * Mon Jul 27 2020 Oyvind Albrigtsen - 4.1.1-64 - nfsserver: fix NFSv4-only support - azure-events: new resource agent for Azure @@ -1112,11 +1117,9 @@ ccs_update_schema > /dev/null 2>&1 ||: Resolves: rhbz#1814896 * Wed Jun 10 2020 Oyvind Albrigtsen - 4.1.1-55 -- azure-events: handle exceptions in urlopen - nfsserver: dont log error message when /etc/sysconfig/nfs does not exist - exportfs: describe clientspec format in metadata - Resolves: rhbz#1845574 Resolves: rhbz#1845581 Resolves: rhbz#1845583