diff options
| author | Soren Hansen <soren.hansen@rackspace.com> | 2010-09-23 17:33:17 +0000 |
|---|---|---|
| committer | Tarmac <> | 2010-09-23 17:33:17 +0000 |
| commit | 421d7a90ea33e80f92039eefaf920c96ae9773cb (patch) | |
| tree | a5cf629e76889dce177f6056bb6a544e8236ba1e | |
| parent | ce0a9b7b36ba816c347f10a1804aedf337ad35da (diff) | |
| parent | 08622cb48c200aa27e214fb14e47a741069b9bb0 (diff) | |
| download | nova-421d7a90ea33e80f92039eefaf920c96ae9773cb.tar.gz nova-421d7a90ea33e80f92039eefaf920c96ae9773cb.tar.xz nova-421d7a90ea33e80f92039eefaf920c96ae9773cb.zip | |
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).
| -rw-r--r-- | nova/scheduler/driver.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/nova/scheduler/driver.py b/nova/scheduler/driver.py index 2e6a5a835..c89d25a47 100644 --- a/nova/scheduler/driver.py +++ b/nova/scheduler/driver.py @@ -42,7 +42,8 @@ class Scheduler(object): def service_is_up(service): """Check whether a service is up based on last heartbeat.""" last_heartbeat = service['updated_at'] or service['created_at'] - elapsed = datetime.datetime.now() - last_heartbeat + # Timestamps in DB are UTC. + elapsed = datetime.datetime.utcnow() - last_heartbeat return elapsed < datetime.timedelta(seconds=FLAGS.service_down_time) def hosts_up(self, context, topic): |
