Skip to content

Commit

Permalink
Use correct server's start time
Browse files Browse the repository at this point in the history
When a machine is resized, rescued or evacuated the server's start_time
(and the usages' start_time) is reset and it does not reflect anymore
the time the instance was created. Instead of relying on that time, we
move to use the server.created time.

This solves the issue of negative accounting times, that happen when an
instance has its start_time reset.

Fixes #56
  • Loading branch information
root authored and alvarolopez committed Dec 18, 2018
1 parent ab2f137 commit 2c87038
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion caso/extract/nova.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def extract_for_project(self, project, extract_from, extract_to):
records[instance_id].disk = usage["local_gb"]

# Start time must be the time when the machine was created
started = dateutil.parser.parse(usage["started_at"])
started = server_start
records[instance_id].start_time = int(started.strftime("%s"))

# End time must ben the time when the machine was ended, but it may
Expand Down

0 comments on commit 2c87038

Please sign in to comment.