Skip to content

Commit

Permalink
'URLError' is not defined and specific ocf-exit-reason if IMDS inacce…
Browse files Browse the repository at this point in the history
…ssible to allow more targeted troubleshooting
  • Loading branch information
rfparedes committed Dec 5, 2020
1 parent 2ff804d commit 4f6f5e9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions heartbeat/azure-events.in
Expand Up @@ -90,13 +90,14 @@ class azHelper:
req.add_header("User-Agent", USER_AGENT)
try:
resp = urllib2.urlopen(req)
except URLError as e:
except urllib2.URLError as e:
if hasattr(e, 'reason'):
ocf.logger.warning("Failed to reach the server: %s" % e.reason)
ocf.ocf_exit_reason("Failed to reach the server: %s" % e.reason)
clusterHelper.setAttr(attr_globalPullState, "IDLE")
elif hasattr(e, 'code'):
ocf.logger.warning("The server couldn\'t fulfill the request. Error code: %s" % e.code)
ocf.ocf_exit_reason("The server couldn\'t fulfill the request. Error code: %s" % e.code)
clusterHelper.setAttr(attr_globalPullState, "IDLE")
exit(ocf.OCF_ERR_GENERIC)
else:
data = resp.read()
ocf.logger.debug("_sendMetadataRequest: response = %s" % data)
Expand Down

0 comments on commit 4f6f5e9

Please sign in to comment.