Add version string to status string
Sometimes debugging puppet deployment issues is difficult without knowing exactly which version of the code is actually running. To help debug automated deployment issues being able to query the exact version running is useful. This commit does this by adding the version string to the /status response so we can easily tell which version is running. Change-Id: I4a26cf097cd1efc9962911e7b5824eb6b8b2f5d9
This commit is contained in:
parent
cabf3f81a2
commit
769f9d3cd7
|
@ -32,6 +32,7 @@ from flask import make_response
|
|||
from flask import request
|
||||
from flask_jsonpify import jsonify
|
||||
from operator import itemgetter
|
||||
from pbr import version
|
||||
import pyelasticsearch
|
||||
import pytz
|
||||
from sqlalchemy import create_engine
|
||||
|
@ -651,10 +652,14 @@ def get_status():
|
|||
is_db_available = _check_db_availability()
|
||||
is_er_available = _check_er_availability()
|
||||
|
||||
status = {'status': {'availability': {
|
||||
status = {'status': {
|
||||
'availability': {
|
||||
'database': is_db_available,
|
||||
'elastic-recheck': is_er_available
|
||||
}}}
|
||||
'elastic-recheck': is_er_available,
|
||||
},
|
||||
'version': version.VersionInfo(
|
||||
'openstack_health').version_string_with_vcs()
|
||||
}}
|
||||
response = jsonify(status)
|
||||
|
||||
if not is_db_available:
|
||||
|
|
|
@ -21,6 +21,7 @@ from dateutil import parser as date_parser
|
|||
import feedparser
|
||||
import mock
|
||||
import numpy
|
||||
from pbr import version
|
||||
import six
|
||||
from subunit2sql.db import models
|
||||
|
||||
|
@ -686,10 +687,14 @@ class TestRestAPI(base.TestCase):
|
|||
return_value='NotInstalled')
|
||||
def test_get_status_failure_er_not_installed(self, status_check_mock,
|
||||
er_mock):
|
||||
expected_response = {'status': {'availability': {
|
||||
expected_response = {'status': {
|
||||
'availability': {
|
||||
'database': False,
|
||||
'elastic-recheck': 'NotInstalled'
|
||||
}}}
|
||||
},
|
||||
'version': version.VersionInfo(
|
||||
'openstack_health').version_string_with_vcs()
|
||||
}}
|
||||
response = self.app.get('/status')
|
||||
self.assertEqual(response.status_code, 500)
|
||||
self.assertEqual(json.loads(response.data.decode('utf-8')),
|
||||
|
@ -701,10 +706,14 @@ class TestRestAPI(base.TestCase):
|
|||
return_value='NotConfigured')
|
||||
def test_get_db_status_success_er_not_configured(self, status_check_mock,
|
||||
er_mock):
|
||||
expected_response = {'status': {'availability': {
|
||||
expected_response = {'status': {
|
||||
'availability': {
|
||||
'database': True,
|
||||
'elastic-recheck': 'NotConfigured'
|
||||
}}}
|
||||
},
|
||||
'version': version.VersionInfo(
|
||||
'openstack_health').version_string_with_vcs()
|
||||
}}
|
||||
response = self.app.get('/status')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
output = json.loads(response.data.decode('utf-8'))
|
||||
|
@ -715,10 +724,14 @@ class TestRestAPI(base.TestCase):
|
|||
@mock.patch('openstack_health.api._check_er_availability',
|
||||
return_value={'Configured': {'elastic-search': 'green'}})
|
||||
def test_get_db_status_success_er_green(self, status_check_mock, er_mock):
|
||||
expected_response = {'status': {'availability': {
|
||||
expected_response = {'status': {
|
||||
'availability': {
|
||||
'database': True,
|
||||
'elastic-recheck': {'Configured': {'elastic-search': 'green'}}
|
||||
}}}
|
||||
},
|
||||
'version': version.VersionInfo(
|
||||
'openstack_health').version_string_with_vcs()
|
||||
}}
|
||||
response = self.app.get('/status')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
output = json.loads(response.data.decode('utf-8'))
|
||||
|
|
Loading…
Reference in New Issue