Updated openstack/openstack
Project: openstack/swift  eacc8e4d690204a6ed41fbba85365a0a9c5e7f9e

Fix last_modified_date_to_timestamp on non-UTC systems

Before, we were calling datetime.datetime.strftime('%s.%f') to convert
a datetime to epoch seconds + microseconds. However, the '%s' format
isn't actually part of Python's library. Rather, Python passes that on
to the system C library, which is typically glibc. Now, glibc takes
the '%s' format and helpfully* applies the current timezone as an
offset. This gives bogus results on machines where UTC is not the
system timezone. (Yes, some people really do that.)

For example:

    >>> import os
    >>> from swift.common import utils
    >>> os.environ['TZ'] = 'PST8PDT,M3.2.0,M11.1.0'
    >>> float(utils.last_modified_date_to_timestamp('1970-01-01T00:00:00.000000'))
    28800.0
    >>>

That timestamp should obviously be 0.

This patch replaces the strftime() call with datetime arithmetic,
which is entirely in Python so the system timezone doesn't mess it up.

* unhelpfully

Change-Id: I56855acd79a5d8f2c98a771fa9fd2729e4f490b1
Updated openstack/openstack
Project: openstack/swift  8bb33cd6738b67e5075e01a1c82c782201961550

Combine acc/cont put_* methods and fix their lock problem.

The container backend is supposed to build a pending file and,
when it gets to a certain size, flush it all at once into the
sqlite db. Before this fix, many concurrent threads would ask
what the pending file size is to see if they should flush
instead of just appending to the pending file. The problem is
that many would ask, find it's too big, and try to get a lock.
The first one wins, flushes, but all the other waiting threads
still think they have to flush- which is a much slower opertaion
than just the append. This change gets the lock first and makes
sure that merge_items is only called when the pending file is full.

Change-Id: I29cfa13a48c8f7d16dd414b2288d50461adbafd2