Commit 6177890b authored by Michele Tartara's avatar Michele Tartara

Improve RAPI detection of the watcher

If the watcher is not allowed to access RAPI, it doesn't mean that it is dead
and needs to be restarted.

Fixes Issue 752.
Signed-off-by: default avatarMichele Tartara <mtartara@google.com>
Reviewed-by: default avatarHrvoje Ribicic <riba@google.com>
parent b7630577
......@@ -329,6 +329,10 @@ def IsRapiResponding(hostname):
Connects to RAPI port of hostname and does a simple test. At this time, the
test is GetVersion.
If RAPI responds with error code "401 Unauthorized", the test is successful,
because the aim of this function is to assess whether RAPI is responding, not
if it is accessible.
@type hostname: string
@param hostname: hostname of the node to connect to.
@rtype: bool
......@@ -344,8 +348,12 @@ def IsRapiResponding(hostname):
logging.warning("RAPI certificate error: %s", err)
return False
except rapi.client.GanetiApiError, err:
logging.warning("RAPI error: %s", err)
return False
if err.code == 401:
# Unauthorized, but RAPI is alive and responding
return True
else:
logging.warning("RAPI error: %s", err)
return False
else:
logging.debug("Reported RAPI version %s", master_version)
return master_version == constants.RAPI_VERSION
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment