Update is_up from Service OVO class to match ORM

Our services' update_at field is also being updated now on creation [1],
so there's no longer a need to check for the created_at field for the
heartbeat in is_up method.

Since this change was introduced in Newton it is now safe for this patch
to remove the unnecessary check on created_at in method is_up of the
Service OVO class.

[1] https://review.openstack.org/#/c/318572/22/cinder/db/sqlalchemy/models.py@73

Trivialfix

Change-Id: Id0e30656901810128415fd9544c28cafb22c6592
This commit is contained in:
Gorka Eguileor 2016-12-21 20:44:01 +01:00
parent 4fef72f32f
commit 6f72616c55
2 changed files with 3 additions and 4 deletions

View File

@ -194,9 +194,8 @@ class Service(base.CinderPersistentObject, base.CinderObject,
@property
def is_up(self):
"""Check whether a service is up based on last heartbeat."""
last_heartbeat = self.updated_at or self.created_at
return (last_heartbeat and
last_heartbeat >= utils.service_expired_time(True))
return (self.updated_at and
self.updated_at >= utils.service_expired_time(True))
@base.CinderObjectRegistry.register

View File

@ -30,7 +30,7 @@ def fake_db_service(**updates):
NOW = timeutils.utcnow().replace(microsecond=0)
db_service = {
'created_at': NOW,
'updated_at': None,
'updated_at': NOW,
'deleted_at': None,
'deleted': False,
'id': 123,