Fix service alive information in os-services extension
Service alive information need to be compared with service_down_time value and updated accordingly. Change-Id: I9b9798c108a2da07ab78d5d05cbb51a73b14363e
This commit is contained in:
parent
6f3b40c59d
commit
276ccf1e81
|
@ -16,6 +16,7 @@
|
|||
# under the License.
|
||||
|
||||
|
||||
from oslo.config import cfg
|
||||
import webob.exc
|
||||
|
||||
from cinder.api import extensions
|
||||
|
@ -28,6 +29,8 @@ from cinder.openstack.common import timeutils
|
|||
from cinder import utils
|
||||
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
authorize = extensions.extension_authorizer('volume', 'services')
|
||||
|
||||
|
@ -81,7 +84,7 @@ class ServiceController(object):
|
|||
svcs = []
|
||||
for svc in services:
|
||||
delta = now - (svc['updated_at'] or svc['created_at'])
|
||||
alive = abs(utils.total_seconds(delta))
|
||||
alive = abs(utils.total_seconds(delta)) <= CONF.service_down_time
|
||||
art = (alive and "up") or "down"
|
||||
active = 'enabled'
|
||||
if svc['disabled']:
|
||||
|
|
|
@ -143,11 +143,11 @@ class ServicesTest(test.TestCase):
|
|||
'updated_at': datetime(2012, 10, 29, 13, 42, 5)},
|
||||
{'binary': 'cinder-scheduler', 'host': 'host2',
|
||||
'zone': 'cinder',
|
||||
'status': 'enabled', 'state': 'up',
|
||||
'status': 'enabled', 'state': 'down',
|
||||
'updated_at': datetime(2012, 9, 19, 6, 55, 34)},
|
||||
{'binary': 'cinder-volume', 'host': 'host2',
|
||||
'zone': 'cinder',
|
||||
'status': 'disabled', 'state': 'up',
|
||||
'status': 'disabled', 'state': 'down',
|
||||
'updated_at': datetime(2012, 9, 18, 8, 3, 38)}]}
|
||||
self.assertEqual(res_dict, response)
|
||||
|
||||
|
@ -183,7 +183,7 @@ class ServicesTest(test.TestCase):
|
|||
'host': 'host2',
|
||||
'zone': 'cinder',
|
||||
'status': 'disabled',
|
||||
'state': 'up',
|
||||
'state': 'down',
|
||||
'updated_at': datetime(2012, 9, 18,
|
||||
8, 3, 38)}]}
|
||||
self.assertEqual(res_dict, response)
|
||||
|
|
Loading…
Reference in New Issue