diff --git a/lib/cli.py b/lib/cli.py index 76234c205f71a46fa7a0785a11982f45020813e3..34657a0e0033475149876f16b5b2a81be486bc2e 100644 --- a/lib/cli.py +++ b/lib/cli.py @@ -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" diff --git a/lib/constants.py b/lib/constants.py index a767fce9a5b4626976c9cf02c116fba1c901bdac..56e5ec04423b28086d8ec35e763c1a3847121e2a 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -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 diff --git a/man/ganeti.rst b/man/ganeti.rst index 16800d128253cb924441fda24b300d23b2a5e7dd..e3efff9dd554cc82aa81276cd474c97c0b732a65 100644 --- a/man/ganeti.rst +++ b/man/ganeti.rst @@ -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 ----------------