Commit 7189e790 authored by Guido Trotter's avatar Guido Trotter
Browse files

querylib: abstract a couple of common errors



Rather than composing them every time, we'll keep "ready-made" tuples
for unknown entries and internal errors (which is, yet, unused)
Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent ae130c81
......@@ -25,6 +25,11 @@
from ganeti import constants
# constants for some common errors to return from a query
QUERY_UNKNOWN_ENTRY_ERROR = (constants.CONFD_REPL_STATUS_ERROR,
constants.CONFD_ERROR_UNKNOWN_ENTRY)
QUERY_INTERNAL_ERROR = (constants.CONFD_REPL_STATUS_ERROR,
constants.CONFD_ERROR_INTERNAL)
class ConfdQuery(object):
"""Confd Query base class.
......@@ -93,9 +98,7 @@ class NodeRoleQuery(ConfdQuery):
return status, answer
flags = self.reader.GetNodeStatusFlags(node)
if flags is None:
status = constants.CONFD_REPL_STATUS_ERROR
answer = constants.CONFD_ERROR_UNKNOWN_ENTRY
return status, answer
return QUERY_UNKNOWN_ENTRY_ERROR
master_candidate, drained, offline = flags
if master_candidate:
......
......@@ -654,6 +654,7 @@ CONFD_REPL_STATUSES = frozenset([
# A few common errors for confd
CONFD_ERROR_UNKNOWN_ENTRY = 1
CONFD_ERROR_INTERNAL = 2
# Each request is "salted" by the current timestamp.
# This constants decides how many seconds of skew to accept.
......
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