Skip to content

Commit

Permalink
Remove microseconds before time format conversion.
Browse files Browse the repository at this point in the history
Updates Glance scrubber so that it chops microseconds off of the
date format before parsing a time format string. This fixes
an exceptions that can occur when using scrubber with databases
like PostgreSQL which include microseconds in date strings.

Fixes LP Bug #1022369.

Change-Id: I2e9eb66052d8ce34438a4c1ba7a5174cc2385bcf
  • Loading branch information
dprince committed Jul 11, 2012
1 parent 77d534e commit ade7b4f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion glance/store/scrubber.py
Expand Up @@ -159,7 +159,10 @@ def _cleanup(self, pool):
continue

time_fmt = "%Y-%m-%dT%H:%M:%S"
delete_time = calendar.timegm(time.strptime(deleted_at,
# NOTE: Strip off microseconds which may occur after the last '.,'
# Example: 2012-07-07T19:14:34.974216
date_str = deleted_at.rsplit('.', 1)[0].rsplit(',', 1)[0]
delete_time = calendar.timegm(time.strptime(date_str,
time_fmt))

if delete_time + self.cleanup_time > now:
Expand Down

0 comments on commit ade7b4f

Please sign in to comment.