2623 Commits

Author SHA1 Message Date
Jenkins
af8b6e1d74 Merge "Move common code into a separate function." 2013-05-21 07:00:37 +00:00
Jenkins
4a1f3d3e1a Merge "Add ability to save builder data to a disk file" 2013-05-21 06:13:46 +00:00
Jenkins
7bc9b0cb15 Merge "Set TZ environment variable to avoid a stat call" 2013-05-21 01:04:44 +00:00
Jenkins
53f3c61adf Merge "Fix two documentation warnings." 2013-05-21 01:04:41 +00:00
Jenkins
d1f1e9fb67 Merge "Don't delete containers when they weren't created." 2013-05-21 01:04:38 +00:00
Peter Portante
306c7549ec Set TZ environment variable to avoid a stat call
By setting the TZ environment variable for the WSGI process we avoid
the stat("/etc/localtime") on every request handled that logs using
strftime().

Change-Id: Ifc78236a99ed193a42389e383d062b38f57a5a31
Signed-off-by: Peter Portante <peter.portante@redhat.com>
2013-05-20 17:29:20 -04:00
Shri Javadekar
6acac14aaf Move common code into a separate function.
test_get_valid and test_get_valid_key2 test tempurl with a
single key and two keys respectively. This change moves common code
for these tests into a separate function.

Change-Id: Ifee211285e27df03d041a4c357b7c1f0c96ed6a8
2013-05-17 09:54:52 -07:00
gholt
69cf78bb16 Moved tests for moved obj.base code
Follow-on to https://review.openstack.org/#/c/28895/

Moved the tests for the code that was moved to obj.base and also made
the new test file flake8 compliant.

Change-Id: I4be718927b6cd2de8efe32f8e54b458a4e05291b
2013-05-17 14:27:13 +00:00
Jenkins
d754b59cf8 Merge "Moved some code out of swift.obj.replicator" 2013-05-17 04:47:21 +00:00
Jenkins
b358a5cc2c Merge "Autocreate cleanups" 2013-05-17 04:26:37 +00:00
Jenkins
7d765bb347 Merge "Remove dead code." 2013-05-16 23:09:56 +00:00
David Hadas
fd3acd2e59 Autocreate cleanups
Autocreate was messy - now cleaned.
Auto-create now occurs at account POST, and container PUT only.
A method for autocreation was added
Autocreation was removed from account_info and container_info.

Fake-it as if the account exists on account HEAD and account GET.

Return 404 on everything else when the account does not exist.

Fix: Bug #1172223
Fix: Bug #1179140
Change-Id: Iac54c1438eb09883fbc29a1ad2ac2245b95efc92
2013-05-16 20:54:05 +03:00
Ilya Kharin
cc040a9c29 Add ability to save builder data to a disk file
Instances of the RingBuilder class can store its data to a disk file by
the save method and load it by the load method.

blueprint argparse-in-swift-ring-builder

Change-Id: I69fdf0693ca9f520d235a795ecdd2da310dcd5d3
2013-05-16 19:49:00 +04:00
Jenkins
678a3ae832 Merge "Skip IPv6 addresses in cname_lookup middleware." 2013-05-16 12:48:35 +00:00
Jenkins
d85e090a14 Merge "Metadata retrieving from sqlite must be str for key" 2013-05-16 12:37:33 +00:00
Jenkins
959f5e7ea8 Merge "Implementation of replication servers" 2013-05-16 02:43:49 +00:00
Samuel Merritt
dc10d9993b Remove dead code.
While it is true that one *could* call ContainerBroker.get_info() with
include_metadata=True, it is also true that nobody actually does.

It's also true that the code path taken when include_metadata=True is
broken in the case of non-ASCII metadata keys
(e.g. X-Container-Meta-☃: snowman), so leaving it around is just
asking for future pain.

Change-Id: I4931add4b8fb7c4f57820e52f182c21040d8db10
2013-05-15 16:53:17 -07:00
Jenkins
50157243dd Merge "Refactor Bulk middleware to handle long running requests" 2013-05-15 23:14:15 +00:00
Fabien Boucher
e7ce290904 Metadata retrieving from sqlite must be str for key
Encode metadata key as utf8 if key is unicode when
retriving it from sqlite database.

Change-Id: I4ba11543d1bed17098b5e52dd768c75b403188a1
Fixes: bug #1172202
2013-05-15 17:04:03 +02:00
Peter Portante
81623cfa2c Perform mount check after REST params valid on PUT
All the other methods (POST, GET, HEAD, DELETE and REPLICATE) first
validate the REST parameters and headers before performing the mount
check. Do the same for PUT.

Change-Id: I6e5f34cc65b57662b7f88224ca0e1501787e0f43
Signed-off-by: Peter Portante <peter.portante@redhat.com>
2013-05-14 12:07:21 -04:00
Jenkins
884b7bb8f8 Merge "Fix obscure double url bug in container quota middleware" 2013-05-13 20:28:05 +00:00
Greg Lange
597072cc95 Fix obscure double url bug in container quota middleware
With the container quota middleware on, if you made a request similar to the
following one you'd get a 500 response.

curl -i -X PUT -H 'X-Auth-Token: token'
http://127.0.0.1:8080/v1/AUTH_testhttp://something/something_else

(Note the double url.)

This was due to a mismatch in how split_path() was called in the middleware and
in the get_container_info().

This change fixes that mismatch and the bug.

Change-Id: Ie42ab585b942b7201e13b02a0c706532952aac60
2013-05-13 19:17:31 +00:00
Peter Portante
8825c9c74a Enhance log msg to report referer and user-agent
Enhance internally logged messages to report referer and user-agent.

Pass the referering URL and METHOD between internal servers (when
known), and set the user-agent to be the server type (obj-server,
container-server, proxy-server, obj-updater, obj-replicator,
container-updater, direct-client, etc.) with the process PID. In
conjunction with the transaction ID, it helps to track down which PID
from a given system was responsible for initiating the request and
what that server was working on to make this request.

This has been helpful in tracking down interactions between object,
container and account servers.

We also take things a bit further performaing a bit of refactoring to
consolidate calls to transfer_headers() now that we have a helper
method for constructing them.

Finally we performed further changes to avoid header key duplication
due to string literal header key values and the various objects
representing headers for requests and responses. See below for more
details.

====

Header Keys

There seems to be a bit of a problem with the case of the various
string literals used for header keys and the interchangable way
standard Python dictionaries, HeaderKeyDict() and HeaderEnvironProxy()
objects are used.

If one is not careful, a header object of some sort (one that does not
normalize its keys, and that is not necessarily a dictionary) can be
constructed containing header keys which differ only by the case of
their string literals. E.g.:

   { 'x-trans-id': '1234', 'X-Trans-Id': '5678' }

Such an object, when passed to http_connect() will result in an
on-the-wire header where the key values are merged together, comma
separated, that looks something like:

   HTTP_X_TRANS_ID: 1234,5678

For some headers in some contexts, this is behavior is desirable. For
example, one can also use a list of tuples which enumerate the multiple
values a single header should have.

However, in almost all of the contexts used in the code base, this is
not desirable.

This behavior arises from a combination of factors:

   1. Header strings are not constants and different lower-case and
      title-case header strings values are used interchangably in the
      code at times

      It might be worth the effort to make a pass through the code to
      stop using string literals and use constants instead, but there
      are plusses and minuses to doing that, so this was not attempted
      in this effort

   2. HeaderEnvironProxy() objects report their keys in ".title()"
      case, but normalize all other key references to the form
      expected by the Request class's environ field

      swob.Request.headers fields are HeaderEnvironProxy() objects.

   3. HeaderKeyDict() objects report their keys in ".lower()" case,
      and normalize all other key references to ".lower()" case

      swob.Response.headers fields are HeaderKeyDict() objects.

Depending on which object is used and how it is used, one can end up
with such a mismatch.

This commit takes the following steps as a (PROPOSED) solution:

   1. Change HeaderKeyDict() to normalize using ".title()" case to
      match HeaderEnvironProxy()

   2. Replace standard python dictionary objects with HeaderKeyDict()
      objects where possible

      This gives us an object that normalizes key references to avoid
      fixing the code to normalize the string literals.

   3. Fix up a few places to use title case string literals to match
      the new defaults

Change-Id: Ied56a1df83ffac793ee85e796424d7d20f18f469
Signed-off-by: Peter Portante <peter.portante@redhat.com>
2013-05-13 17:39:02 +00:00
Jenkins
7d625f6ea4 Merge "Allow 2 TempURL keys per account." 2013-05-12 01:35:54 +00:00
Jenkins
1abe5ddc4f Merge "Doc changes for new pip-requirements" 2013-05-11 22:16:17 +00:00
gholt
9fe15dd15a Moved some code out of swift.obj.replicator
This will be needed in future replication work to avoid circular
imports.

I used swift.obj.base as the module name just because we seemed to
avoid putting code in __init__.py files so far and I didn't want to
buck the trend.

I would love to see other obj things like *_metadata and DiskFile
move into swift.obj.base as well and swift.obj.server just be the
WSGI server logic, but I'll leave that for the future.

I have changed the tests as little as possible (just the references
to where they get the code to test) to show the refactor has not
broken anything. I did add a test for tpool_reraise since there was
none before.

There will be a follow on patch for moving the tests to their new
location(s). I figured I'd wait to put the bikes in the shed until
everyone's done painting it.

Change-Id: I32b4ac88be21eb76c877d3f4cc1e6ac33304835b
2013-05-11 21:48:00 +00:00
Darrell Bishop
4f2f2435ac Fix two documentation warnings.
The crossdomain doc was named *.xml instead of *.rst causing it to not
get built or included in the toctree where it was supposed to.

The apache deployment guide wasn't linked to from anywhere, so I added
it under the normal deployment guide.

Change-Id: I817a1f2ca1ed7913e8ea5155cc1fac07caf0b637
2013-05-11 14:31:42 -07:00
Darrell Bishop
5f295d0329 Don't delete containers when they weren't created.
When swift-bench is run in direct mode, don't try to delete the
containers which weren't created.

Fixes bug 1177960.

Change-Id: Ice07e8729bb776e2b215894cf95fb80b64167a8d
2013-05-11 13:37:16 -07:00
David Goetz
af2607c457 Refactor Bulk middleware to handle long running requests
Change-Id: I8ea0ff86518d453597faae44ec3918298e2d5147
2013-05-08 10:00:21 -07:00
Samuel Merritt
21343ab038 Allow 2 TempURL keys per account.
This allows users to rotate their TempURL keys without invalidating
all existing signed URLs. This is handy if you have multiple systems
generating signed URLs, but you want to change your keys for some
reason (e.g. keys compromised, company policy, general paranoia).

Both the first and second keys are optional, so existing accounts'
signed URLs will continue to work as before.

This commit does change the memcache key used to store the fetched
TempURL keys. This is because we were storing the old key as a string
in memcached, but the new one is a list of keys. Since the key cache
lifetime here is only 60 seconds, it doesn't seem like too big a deal
to completely flush the TempURL cache.

Also, this commit adds caching of a negative TempURL result. If the
account HEAD reveals no TempURL keys at all, that result is now stored
for 60 seconds the same way that a positive result would be.

Change-Id: I40a02bd607283fbce11aa52a9bb8a5846ab17f5e
2013-05-07 22:25:43 +00:00
Jenkins
c3e6f3a1d6 Merge "have tempurl allow OPTIONS requests" 2013-05-07 22:19:18 +00:00
David Goetz
d3bc10d0d7 have tempurl allow OPTIONS requests
Change-Id: I431cac1e9818a335ff8d20288ab6acf39d6b6d5e
2013-05-07 14:08:27 -07:00
Edward Hope-Morley
f9c5348f49 Fixed issue with use of delimiter in container queries.
Currently if you have a container with objects named
x/y and x0 and you use delimiter=/ in your query, x0
will be excluded from the results. This patch resolves
this problem.

To replicate the original issue, create a container
called 'test' with the following objects:

x/y
x0
x1

Then do a GET with 'accnt/test?delimiter=/' and the
following is returned:

x/
x1

i.e. x0 is missing from output.

Change-Id: If196e3075612b121ef8da4a9128167d00a248c27
2013-05-07 19:33:37 +01:00
David Hadas
39fc4c37bf Doc changes for new pip-requirements
dnspython was added recently to the list of requirments.

This patch completes the change:
1. The new requirement is documented
2. The need for tox --recreate is documented
(assuming there is no way to automate 2 above)

Change-Id: I49f0cb4b01b79dd7cf4329984a2f8416378ebe19
Fixes: Bug #1176627
2013-05-06 19:21:53 +03:00
Jenkins
506a2b1fd0 Merge "Adds chunk_size to CompressingFileReader." 2013-05-04 17:08:33 +00:00
Jenkins
4074ba93f5 Merge "Fix rebalance for zero weighted devices." 2013-05-04 17:03:31 +00:00
Samuel Merritt
e3da6b07a0 Skip IPv6 addresses in cname_lookup middleware.
It already skips IPv4 addresses, and since IPv6 is the future of the
Internet*, we should probably do the right thing with those too.

* IPv6: Just two years away for over fifteen years!

Change-Id: I54f1db4e936fd38d05ac8b5c709efba76525b9d2
2013-05-03 14:08:08 -07:00
Matthieu Huin
b61b177a3f Skip cname_lookup when host is an IP address
cname_lookup cannot resolve IP addresses as CNAME records, and therefore
should not attempt to resolve the host in that case. The middleware is
skipped when the host is an IP address.

Change-Id: I6961ec205e771116ace1ebcb8c088f3116eb38f0
Fixes: bug #1172289
2013-05-03 17:48:31 +02:00
Jenkins
b9a6bcb431 Merge "Add an explicit unit test for handling content-length: 0" 2013-05-03 11:47:19 +00:00
Jenkins
f7b4a6d0ce Merge "conf.d support" 2013-05-03 02:27:00 +00:00
Peter Portante
99891e0d2e Rename "file" to "disk_file"
Broke this out into a separate commit since adding five characters
caused a few lines to get re-wrapped, adding more diffs.

See John's comment from Patch Set #3 for the motivation for this
change in review https://review.openstack.org/27149.

Change-Id: I1edf2cb468dcda0b781569161ada6e4016c1141c
Signed-off-by: Peter Portante <peter.portante@redhat.com>
2013-05-01 22:25:08 -04:00
Jenkins
8ecf77efa2 Merge "Update to flake8 instead of pep8." 2013-05-02 01:17:14 +00:00
Greg Lange
5fda0c9a77 Adds chunk_size to CompressingFileReader.
Before when iterating using this object, the call to the underlying file object
was made without a chunk_size.  This is bad because this would cause the entire
contents of the file to be read.

Change-Id: I9956e5d2d693a6260252fff331d4f78f70179a6c
2013-05-01 21:16:18 +00:00
Monty Taylor
de2e5aa462 Update to flake8 instead of pep8.
Change-Id: I3d4a31111c3044da06611405ce80f208ef8a0ce3
2013-05-01 14:19:38 -04:00
Brian Cline
d69fa437cd Uses None instead of mutable dicts for default function arguments
Forgot to update dicts with changeset I4a89afad, which updated lists.

Change-Id: Ieca71b9c90ee5dae83a43f6851b6b8b2924bcb8e
Fixes: bug 1174809
2013-04-30 15:36:48 -05:00
Brian Cline
7bf0db6b75 Uses None instead of mutable lists for function param defaults
Addressing bug 1174809, changes use of mutable lists as as default
arguments and defaults them within the function. Otherwise, those
defaults can be unexpectedly persisted with the function between
invocations and erupt into mass hysteria on the streets.

To my knowledge there aren't known cases of the current use causing
specific issues, but even stylistically needs addressing to avoid
problems in the future. I couldn't find any comments or related
historical commit messages indicating the current use is meant to take
advantage of this behavior in Python.

Change-Id: I4a89afada08b2ce220724f585631a9e2072bf1bd
Fixes: bug 1174809
2013-04-30 11:24:40 -05:00
Jenkins
b1f28c741d Merge "Container info memcache change broke ratelimiting." 2013-04-30 07:22:14 +00:00
Clay Gerrard
34f5085c3e conf.d support
Allow Swift daemons and servers to optionally accept a directory as the
configuration parameter.  Directory based configuration leverages
ConfigParser's native multi-file support.  Files ending in '.conf' in the
given directory are parsed in lexicographical order.  Filenames starting with
'.' are ignored.  A mixture of file and directory configuration paths is not
supported - if the configuration path is a file behavior is unchanged.

 * update swift-init to search for conf.d paths when building servers
    (e.g. /etc/swift/proxy-server.conf.d/)
 * new script swift-config can be used to inspect the cumulative configuration
 * pull a little bit of code out of run_wsgi and test separately
 * fix example config bug for the proxy servers client_disconnect option
 * added section on directory based configuration to deployment guide

DocImpact

Implements: blueprint confd
Change-Id: I89b0f48e538117f28590cf6698401f74ef58003b
2013-04-30 00:17:46 -07:00
Jenkins
52a6595033 Merge "Add the max_clients parameter to bound clients" 2013-04-30 05:57:10 +00:00
Jenkins
407e08fa30 Merge "Included time inside trans_id" 2013-04-29 18:21:44 +00:00