Commit 055d6ac0 authored by Iustin Pop's avatar Iustin Pop

Add option to redirect luxi socket for debugging

Currently, the choice between masterd and conf/queryd is made
statically, based on whether a query is converted or not and whether
split queries are enabled. This makes it hard to test and develop
these new queries, so this patch adds an override for the socket.

The choice for going with two hardcoded strings and arbitrary socket
fallback is done so that it's easy to use this in virtual clusters as
well.

Additionally, the patch improves the error message on failed connects
when we use arbitrary sockets; before, it always "blamed" confd for
non-master sockets.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 1302ce18
......@@ -2216,7 +2216,15 @@ def GetClient(query=False):
connected to the query socket instead of the masterd socket
"""
if query and constants.ENABLE_SPLIT_QUERY:
override_socket = os.getenv(constants.LUXI_OVERRIDE, "")
if override_socket:
if override_socket == constants.LUXI_OVERRIDE_MASTER:
address = pathutils.MASTER_SOCKET
elif override_socket == constants.LUXI_OVERRIDE_QUERY:
address = pathutils.QUERY_SOCKET
else:
address = override_socket
elif query and constants.ENABLE_SPLIT_QUERY:
address = pathutils.QUERY_SOCKET
else:
address = None
......@@ -2303,10 +2311,12 @@ def FormatError(err):
obuf.write("Failure: unknown/wrong parameter name '%s'" % msg)
elif isinstance(err, luxi.NoMasterError):
if err.args[0] == pathutils.MASTER_SOCKET:
daemon = "master"
daemon = "the master daemon"
elif err.args[0] == pathutils.QUERY_SOCKET:
daemon = "the config daemon"
else:
daemon = "config"
obuf.write("Cannot communicate with the %s daemon.\nIs it running"
daemon = "socket '%s'" % str(err.args[0])
obuf.write("Cannot communicate with %s.\nIs the process running"
" and listening for connections?" % daemon)
elif isinstance(err, luxi.TimeoutError):
obuf.write("Timeout while talking to the master daemon. Jobs might have"
......
......@@ -184,6 +184,10 @@ PROC_MOUNTS = "/proc/mounts"
# Local UniX Interface related constants
LUXI_EOM = "\3"
LUXI_VERSION = CONFIG_VERSION
#: Environment variable for the luxi override socket
LUXI_OVERRIDE = "FORCE_LUXI_SOCKET"
LUXI_OVERRIDE_MASTER = "master"
LUXI_OVERRIDE_QUERY = "query"
# one of "no", "yes", "only"
SYSLOG_USAGE = _autoconf.SYSLOG_USAGE
......
......@@ -267,6 +267,22 @@ and ``gnt-instance list``. So you can configure default command line
flags by setting ``GNT_NODE_LIST``, ``GNT_GROUP_LIST`` and
``GNT_INSTANCE_LIST``.
Debug options
~~~~~~~~~~~~~
If the variable ``FORCE_LUXI_SOCKET`` is set, it will override the
socket used for LUXI connections by command-line tools
(``gnt-*``). This is useful mostly for debugging, and some operations
won't work at all if, for example, you point this variable to the
confd-supplied query socket and try to submit a job.
If the variable is set to the value ``master``, it will connect to the
correct path for the master daemon (even if, for example, split
queries are enabled and this is a query operation). If set to
``query``, it will always (try to) connect to the query socket, even
if split queries are disabled. Otherwise, the value is taken to
represent a filesystem path to the socket to use.
Field formatting
----------------
......
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