Commit 43dc8496 authored by Guido Trotter's avatar Guido Trotter

ClusterMasterQuery: add primary ip field

By allowing also the primary ip field to be fetched directly, we avoid
one more confd lookup, or dns request, to find out which address the
master node lives at.
Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
parent 250554a9
......@@ -94,6 +94,9 @@ class ClusterMasterQuery(ConfdQuery):
It accepts no arguments, and returns the current cluster master.
"""
def _GetMasterNode(self):
return self.reader.GetMasterNode()
def Exec(self, query):
"""ClusterMasterQuery main execution
......@@ -109,9 +112,11 @@ class ClusterMasterQuery(ConfdQuery):
answer = []
for field in req_fields:
if field == constants.CONFD_REQFIELD_NAME:
answer.append(self.reader.GetMasterNode())
answer.append(self._GetMasterNode())
elif field == constants.CONFD_REQFIELD_IP:
answer.append(self.reader.GetMasterIP())
elif field == constants.CONFD_REQFIELD_MNODE_PIP:
answer.append(self.reader.GetNodePrimaryIp(self._GetMasterNode()))
else:
logging.debug("missing FIELDS in query dict")
return QUERY_ARGUMENT_ERROR
......
......@@ -691,6 +691,7 @@ CONFD_REQQ_FIELDS = "3"
CONFD_REQFIELD_NAME = "0"
CONFD_REQFIELD_IP = "1"
CONFD_REQFIELD_MNODE_PIP = "2"
CONFD_REQS = frozenset([
CONFD_REQ_PING,
......
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