From 6f72616c55a5e63d00c822d2dad9b6962080da75 Mon Sep 17 00:00:00 2001 From: Gorka Eguileor Date: Wed, 21 Dec 2016 20:44:01 +0100 Subject: [PATCH] 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 --- cinder/objects/service.py | 5 ++--- cinder/tests/unit/fake_service.py | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/cinder/objects/service.py b/cinder/objects/service.py index bcfe9dfe964..a1706184f3a 100644 --- a/cinder/objects/service.py +++ b/cinder/objects/service.py @@ -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 diff --git a/cinder/tests/unit/fake_service.py b/cinder/tests/unit/fake_service.py index f3a65f1607d..455db247c86 100644 --- a/cinder/tests/unit/fake_service.py +++ b/cinder/tests/unit/fake_service.py @@ -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,