Merge "Show an engine as down if service record is not updated twice" into stable/queens

This commit is contained in:
Zuul 2019-08-08 14:46:16 +00:00 committed by Gerrit Code Review
commit 94f5f3fe25
2 changed files with 10 additions and 14 deletions

View File

@ -51,14 +51,10 @@ def format_service(service):
return return
status = 'down' status = 'down'
if service.updated_at is not None: last_updated = service.updated_at or service.created_at
if ((timeutils.utcnow() - service.updated_at).total_seconds() check_interval = (timeutils.utcnow() - last_updated).total_seconds()
<= service.report_interval): if check_interval <= 2 * service.report_interval:
status = 'up' status = 'up'
else:
if ((timeutils.utcnow() - service.created_at).total_seconds()
<= service.report_interval):
status = 'up'
result = { result = {
SERVICE_ID: service.id, SERVICE_ID: service.id,

View File

@ -51,23 +51,23 @@ class TestServiceUtils(common.HeatTestCase):
self.assertEqual(service_dict['status'], 'up') self.assertEqual(service_dict['status'], 'up')
# check again within first report_interval time (60) # check again within first report_interval time
service_dict = service_utils.format_service(service) service_dict = service_utils.format_service(service)
self.assertEqual(service_dict['status'], 'up') self.assertEqual(service_dict['status'], 'up')
# check update not happen within report_interval time (60+) # check update not happen within 2*report_interval time
service.created_at = (timeutils.utcnow() - service.created_at = (timeutils.utcnow() -
datetime.timedelta(0, 70)) datetime.timedelta(0, 130))
service_dict = service_utils.format_service(service) service_dict = service_utils.format_service(service)
self.assertEqual(service_dict['status'], 'down') self.assertEqual(service_dict['status'], 'down')
# check update happened after report_interval time (60+) # check update happened after 2* report_interval time
service.updated_at = (timeutils.utcnow() - service.updated_at = (timeutils.utcnow() -
datetime.timedelta(0, 70)) datetime.timedelta(0, 130))
service_dict = service_utils.format_service(service) service_dict = service_utils.format_service(service)
self.assertEqual(service_dict['status'], 'down') self.assertEqual(service_dict['status'], 'down')
# check update happened within report_interval time (60) # check update happened within report_interval time
service.updated_at = (timeutils.utcnow() - service.updated_at = (timeutils.utcnow() -
datetime.timedelta(0, 50)) datetime.timedelta(0, 50))
service_dict = service_utils.format_service(service) service_dict = service_utils.format_service(service)