summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorDavid Subiros <david.perez5@hp.com>2011-08-05 16:35:56 +0100
committerStanislaw Pitucha <stanislaw.pitucha@hp.com>2011-10-21 13:32:01 +0100
commitad74424768463cd6ad02dd9d6fdf64fc7b3bbafb (patch)
tree16a7d0d2c6f136af313be72592f28128f6359440 /nova
parent75a3fbb21eebd4de8775b63c327d9d57859d090c (diff)
downloadnova-ad74424768463cd6ad02dd9d6fdf64fc7b3bbafb.tar.gz
nova-ad74424768463cd6ad02dd9d6fdf64fc7b3bbafb.tar.xz
nova-ad74424768463cd6ad02dd9d6fdf64fc7b3bbafb.zip
Improve the liveness checking for services
With this modification both nova-manage and scheduler use the flag service_down_time and check positive and negative values in a correct way. Fixes bug: 867674. Change-Id: I15c48d80cafa2089cd228c09c61b0a1e513730e8
Diffstat (limited to 'nova')
-rw-r--r--nova/scheduler/driver.py6
-rw-r--r--nova/utils.py9
2 files changed, 11 insertions, 4 deletions
diff --git a/nova/scheduler/driver.py b/nova/scheduler/driver.py
index 7bf26cfdf..577503cd8 100644
--- a/nova/scheduler/driver.py
+++ b/nova/scheduler/driver.py
@@ -21,8 +21,6 @@
Scheduler base class that all Schedulers should inherit from
"""
-import datetime
-
from nova import db
from nova import exception
from nova import flags
@@ -143,8 +141,8 @@ class Scheduler(object):
"""Check whether a service is up based on last heartbeat."""
last_heartbeat = service['updated_at'] or service['created_at']
# Timestamps in DB are UTC.
- elapsed = utils.utcnow() - last_heartbeat
- return elapsed < datetime.timedelta(seconds=FLAGS.service_down_time)
+ elapsed = utils.total_seconds(utils.utcnow() - last_heartbeat)
+ return abs(elapsed) <= FLAGS.service_down_time
def hosts_up(self, context, topic):
"""Return the list of hosts that have a running service for topic."""
diff --git a/nova/utils.py b/nova/utils.py
index 7d34a87d8..ad585ba1c 100644
--- a/nova/utils.py
+++ b/nova/utils.py
@@ -1009,3 +1009,12 @@ def make_dev_path(dev, partition=None, base='/dev'):
if partition:
path += str(partition)
return path
+
+
+def total_seconds(td):
+ """Local total_seconds implementation for compatibility with python 2.6"""
+ if hasattr(td, 'total_seconds'):
+ return td.total_seconds()
+ else:
+ return ((td.days * 86400 + td.seconds) * 10 ** 6 +
+ td.microseconds) / 10.0 ** 6