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.
---
daemons/ganeti-masterd | 6 ++++++
lib/cli.py | 5 ++---
lib/luxi.py | 4 ++++
3 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/daemons/ganeti-masterd b/daemons/ganeti-masterd
index 4d783a8..63471d9 100755
--- a/daemons/ganeti-masterd
+++ b/daemons/ganeti-masterd
@@ -299,6 +299,12 @@ class ClientOps:
op = opcodes.OpQueryClusterInfo()
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:
drain_flag = args
logging.info("Received queue drain flag change request to %s",
diff --git a/lib/cli.py b/lib/cli.py
index 41bcc53..bbdb629 100644
--- a/lib/cli.py
+++ b/lib/cli.py
@@ -252,7 +252,6 @@ ARGS_ONE_INSTANCE = [ArgInstance(min=1, max=1)]
ARGS_ONE_NODE = [ArgNode(min=1, max=1)]
-
def _ExtractTagsObject(opts, args):
"""Extract the tag type object.
@@ -313,8 +312,8 @@ def ListTags(opts, args):
"""
kind, name = _ExtractTagsObject(opts, args)
- op = opcodes.OpGetTags(kind=kind, name=name)
- result = SubmitOpCode(op)
+ cl = GetClient()
+ result = cl.QueryTags(kind, name)
result = list(result)
result.sort()
for tag in result:
diff --git a/lib/luxi.py b/lib/luxi.py
index e72d7d0..f062816 100644
--- a/lib/luxi.py
+++ b/lib/luxi.py
@@ -56,6 +56,7 @@ REQ_QUERY_NODES = "QueryNodes"
REQ_QUERY_EXPORTS = "QueryExports"
REQ_QUERY_CONFIG_VALUES = "QueryConfigValues"
REQ_QUERY_CLUSTER_INFO = "QueryClusterInfo"
+REQ_QUERY_TAGS = "QueryTags"
REQ_QUEUE_SET_DRAIN_FLAG = "SetDrainFlag"
REQ_SET_WATCHER_PAUSE = "SetWatcherPause"
@@ -384,5 +385,8 @@ class Client(object):
def QueryConfigValues(self, 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)
--
1.6.5.7