Make health check failures report their reasons
Note that we add a new block with expanded service info, to avoid breaking compatibility with existing callers of the health endpoint
This commit is contained in:
parent
e44a503bd0
commit
4ad3682b9c
4 changed files with 32 additions and 20 deletions
|
@ -120,15 +120,14 @@ class RedisBuildLogs(object):
|
|||
|
||||
connection = redis.StrictRedis(**args)
|
||||
if not connection.ping() == True:
|
||||
return False
|
||||
return (False, 'Could not ping redis')
|
||||
|
||||
# Ensure we can write and read a key.
|
||||
connection.set(self._health_key(), time.time())
|
||||
connection.get(self._health_key())
|
||||
|
||||
return True
|
||||
except redis.RedisError:
|
||||
return False
|
||||
return (True, None)
|
||||
except redis.RedisError as re:
|
||||
return (False, 'Could not connect to redis: %s' % re.message)
|
||||
|
||||
|
||||
class BuildLogs(object):
|
||||
|
|
|
@ -11,12 +11,11 @@ def check_health(app_config):
|
|||
# check).
|
||||
try:
|
||||
validate_database_url(app_config['DB_URI'], {}, connect_timeout=3)
|
||||
except Exception:
|
||||
logger.exception('Could not connect to the database')
|
||||
return False
|
||||
except Exception as ex:
|
||||
return (False, 'Could not connect to the database: %s', ex.message)
|
||||
|
||||
# We will connect to the db, check that it contains some team role kinds
|
||||
try:
|
||||
return bool(list(TeamRole.select().limit(1)))
|
||||
except:
|
||||
return False
|
||||
return (bool(list(TeamRole.select().limit(1))), 'Could not connect to the database')
|
||||
except Exception as ex:
|
||||
return (False, 'Could not connect to the database: %s', ex.message)
|
||||
|
|
Reference in a new issue