Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
...@@ -25,6 +25,11 @@ ...@@ -25,6 +25,11 @@
from ganeti import constants 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): class ConfdQuery(object):
"""Confd Query base class. """Confd Query base class.
...@@ -93,9 +98,7 @@ class NodeRoleQuery(ConfdQuery): ...@@ -93,9 +98,7 @@ class NodeRoleQuery(ConfdQuery):
return status, answer return status, answer
flags = self.reader.GetNodeStatusFlags(node) flags = self.reader.GetNodeStatusFlags(node)
if flags is None: if flags is None:
status = constants.CONFD_REPL_STATUS_ERROR return QUERY_UNKNOWN_ENTRY_ERROR
answer = constants.CONFD_ERROR_UNKNOWN_ENTRY
return status, answer
master_candidate, drained, offline = flags master_candidate, drained, offline = flags
if master_candidate: if master_candidate:
......
...@@ -654,6 +654,7 @@ CONFD_REPL_STATUSES = frozenset([ ...@@ -654,6 +654,7 @@ CONFD_REPL_STATUSES = frozenset([
# A few common errors for confd # A few common errors for confd
CONFD_ERROR_UNKNOWN_ENTRY = 1 CONFD_ERROR_UNKNOWN_ENTRY = 1
CONFD_ERROR_INTERNAL = 2
# Each request is "salted" by the current timestamp. # Each request is "salted" by the current timestamp.
# This constants decides how many seconds of skew to accept. # This constants decides how many seconds of skew to accept.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment