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
|
@ -46,15 +46,29 @@ class HealthCheck(object):
|
|||
is_healthy = True
|
||||
notes = notes or []
|
||||
|
||||
service_statuses_bools = {}
|
||||
service_status_expanded = {}
|
||||
|
||||
for service_name in service_statuses:
|
||||
status, err = service_statuses[service_name]
|
||||
|
||||
service_statuses_bools[service_name] = status
|
||||
service_status_expanded[service_name] = {
|
||||
'status': status,
|
||||
}
|
||||
|
||||
if not status:
|
||||
service_status_expanded[service_name]['failure'] = err
|
||||
|
||||
if skip and service_name in skip:
|
||||
notes.append('%s skipped in compute health' % service_name)
|
||||
continue
|
||||
|
||||
is_healthy = is_healthy and service_statuses[service_name]
|
||||
is_healthy = is_healthy and status
|
||||
|
||||
data = {
|
||||
'services': service_statuses,
|
||||
'services': service_statuses_bools,
|
||||
'services_expanded': service_status_expanded,
|
||||
'notes': notes,
|
||||
'is_testing': self.app.config['TESTING'],
|
||||
'config_provider': self.config_provider.provider_id,
|
||||
|
|
Reference in a new issue