Commit 7699c3af authored by Iustin Pop's avatar Iustin Pop
Browse files

Introduce a Luxi call for GetTags



This changes from submitting jobs to get the tags (in cli scripts) to
queries, which (since the tags query is a cheap one) should be much
faster.

The tags queries are already done without locks (in the generic query
paths for instances/nodes/cluster), so this shouldn't break tags query
via gnt-* list-tags.

On a small cluster, the runtime of gnt-cluster/gnt-instance list tags
more than halves; on a big cluster (with many MCs) I expect it to be
more than 5 times faster. The speed of the tags get is not the main
gain, it is eliminating a job when a simple query is enough.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
parent 47a72f18
...@@ -299,6 +299,12 @@ class ClientOps: ...@@ -299,6 +299,12 @@ class ClientOps:
op = opcodes.OpQueryClusterInfo() op = opcodes.OpQueryClusterInfo()
return self._Query(op) return self._Query(op)
elif method == luxi.REQ_QUERY_TAGS:
kind, name = args
logging.info("Received tags query request")
op = opcodes.OpGetTags(kind=kind, name=name)
return self._Query(op)
elif method == luxi.REQ_QUEUE_SET_DRAIN_FLAG: elif method == luxi.REQ_QUEUE_SET_DRAIN_FLAG:
drain_flag = args drain_flag = args
logging.info("Received queue drain flag change request to %s", logging.info("Received queue drain flag change request to %s",
......
...@@ -252,7 +252,6 @@ ARGS_ONE_INSTANCE = [ArgInstance(min=1, max=1)] ...@@ -252,7 +252,6 @@ ARGS_ONE_INSTANCE = [ArgInstance(min=1, max=1)]
ARGS_ONE_NODE = [ArgNode(min=1, max=1)] ARGS_ONE_NODE = [ArgNode(min=1, max=1)]
def _ExtractTagsObject(opts, args): def _ExtractTagsObject(opts, args):
"""Extract the tag type object. """Extract the tag type object.
...@@ -313,8 +312,8 @@ def ListTags(opts, args): ...@@ -313,8 +312,8 @@ def ListTags(opts, args):
""" """
kind, name = _ExtractTagsObject(opts, args) kind, name = _ExtractTagsObject(opts, args)
op = opcodes.OpGetTags(kind=kind, name=name) cl = GetClient()
result = SubmitOpCode(op) result = cl.QueryTags(kind, name)
result = list(result) result = list(result)
result.sort() result.sort()
for tag in result: for tag in result:
......
...@@ -56,6 +56,7 @@ REQ_QUERY_NODES = "QueryNodes" ...@@ -56,6 +56,7 @@ REQ_QUERY_NODES = "QueryNodes"
REQ_QUERY_EXPORTS = "QueryExports" REQ_QUERY_EXPORTS = "QueryExports"
REQ_QUERY_CONFIG_VALUES = "QueryConfigValues" REQ_QUERY_CONFIG_VALUES = "QueryConfigValues"
REQ_QUERY_CLUSTER_INFO = "QueryClusterInfo" REQ_QUERY_CLUSTER_INFO = "QueryClusterInfo"
REQ_QUERY_TAGS = "QueryTags"
REQ_QUEUE_SET_DRAIN_FLAG = "SetDrainFlag" REQ_QUEUE_SET_DRAIN_FLAG = "SetDrainFlag"
REQ_SET_WATCHER_PAUSE = "SetWatcherPause" REQ_SET_WATCHER_PAUSE = "SetWatcherPause"
...@@ -384,5 +385,8 @@ class Client(object): ...@@ -384,5 +385,8 @@ class Client(object):
def QueryConfigValues(self, fields): def QueryConfigValues(self, fields):
return self.CallMethod(REQ_QUERY_CONFIG_VALUES, fields) return self.CallMethod(REQ_QUERY_CONFIG_VALUES, fields)
def QueryTags(self, kind, name):
return self.CallMethod(REQ_QUERY_TAGS, (kind, name))
# TODO: class Server(object) # TODO: class Server(object)
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