Merge lp:~soren/nova/hosts-up-tz-fix into lp:~hudson-openstack/nova/trunk

Proposed by Soren Hansen
Status: Merged
Approved by: Soren Hansen
Approved revision: 290
Merged at revision: 290
Proposed branch: lp:~soren/nova/hosts-up-tz-fix
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 13 lines (+2/-1)
1 file modified
nova/scheduler/driver.py (+2/-1)
To merge this branch: bzr merge lp:~soren/nova/hosts-up-tz-fix
Reviewer Review Type Date Requested Status
Devin Carlen (community) Approve
Joshua McKenty (community) Approve
Review via email: mp+36421@code.launchpad.net

Commit message

When calculating timedeltas make sure both timestamps are in UTC.
For people ahead of UTC, it makes the scheduler unit tests pass.
For people behind UTC, it makes their services time out after 60 seconds without a heart beat rather than X hours and 60 seconds without a heart beat (where X is the number of hours they're behind UTC).

Description of the change

Make tests pass for non-Americans :)

To post a comment you must log in.
Revision history for this message
Joshua McKenty (joshua-mckenty) wrote :

lgtm.

review: Approve
Revision history for this message
Devin Carlen (devcamcar) wrote :

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nova/scheduler/driver.py'
2--- nova/scheduler/driver.py 2010-09-07 20:01:21 +0000
3+++ nova/scheduler/driver.py 2010-09-23 09:29:55 +0000
4@@ -42,7 +42,8 @@
5 def service_is_up(service):
6 """Check whether a service is up based on last heartbeat."""
7 last_heartbeat = service['updated_at'] or service['created_at']
8- elapsed = datetime.datetime.now() - last_heartbeat
9+ # Timestamps in DB are UTC.
10+ elapsed = datetime.datetime.utcnow() - last_heartbeat
11 return elapsed < datetime.timedelta(seconds=FLAGS.service_down_time)
12
13 def hosts_up(self, context, topic):