15 Commits

Author SHA1 Message Date
Peter Portante
56593a1323 Pep8 unit test modules w/ <= 20 violations (6 of 12)
Change-Id: I7317beb97e1530cb18c62da55ccf4c64206ff362
Signed-off-by: Peter Portante <peter.portante@redhat.com>
2013-09-01 16:12:42 -04:00
Donagh McCabe
eb99e8f84c Obscure the X-Auth-Token in proxy log
The X-Auth-Token is sensitive data. If revealed to an unauthozied person,
they can now make requests against an account until the token expires.

This implementation maintains current behavior (i.e, the token
is logged). Implementers can choose to set reveal_sensitive_prefix
to (e.g.) 12 so only first 12 characters of the token are logged.
Or, set to 0 to replace the token with "...".

DocImpact

Part of bug #1004114

Change-Id: Iecefa843d8f9ef59b9dcf0860e7a4d0e186a6cb5
2013-07-30 09:37:27 +01:00
Alex Gaynor
ff5a6d0111 Corrected many style violations in the tests.
I focussed primarily on F-category violations, they are all but all fixed with
this patch.

Change-Id: I343f6945c97984ed1093bc347b6def6994297041
2013-07-24 10:18:47 -07:00
gholt
04a189676b Added logging of x-delete-at values
Added logging of the x-delete-at value for object PUTs and POSTs and
made the additional log field generic for other similar use cases.

Logging the x-delete-at is useful because otherwise you might never
know why an object "disappeared" just by looking at saved proxy logs.
You'd see a successful PUT of the object followed some time by a GET
that 404s. If you still have the other logs, you could track down
what happened; but, at least with our clusters, we keep proxy logs
forever but only keep the other logs for a short while.

Change-Id: Ida559abcf8dc5666e2a7eea250a67d1c4b28b1be
2013-06-13 15:14:35 +00:00
gholt
cd8af3f8f1 Made colons quote-safe in logs; mainly for ipv6
Previous logging made a mess of ipv6 addresses. This just makes the
colon quote-safe so it passes through unscathed. The logs will still
be backward compatible because unquote don't care:

    $ python
    >>> from urllib import quote, unquote
    >>> quote('2001:db8:85a3:8d3:1319:8a2e:370:7348')
    '2001%3Adb8%3A85a3%3A8d3%3A1319%3A8a2e%3A370%3A7348'
    >>> unquote(quote('2001:db8:85a3:8d3:1319:8a2e:370:7348'))
    '2001:db8:85a3:8d3:1319:8a2e:370:7348'
    >>> quote('2001:db8:85a3:8d3:1319:8a2e:370:7348', '/:')
    '2001:db8:85a3:8d3:1319:8a2e:370:7348'
    >>> unquote(quote('2001:db8:85a3:8d3:1319:8a2e:370:7348', '/:'))
    '2001:db8:85a3:8d3:1319:8a2e:370:7348'

Change-Id: Ia13a9bc8a320cde5c56034a7f0b645913428bf21
2013-04-20 04:26:21 +00:00
Greg Lange
44f00a23c1 fixed some minor things in tests that pyflakes complained about
Change-Id: Ifeab56a964630bcf941e932fcbe39e6572e62975
2013-03-26 20:42:26 +00:00
Darrell Bishop
bce8443c9e Adds first-byte latency timings for GET requests.
This was an oustanding TODO for StatsD Swift metrics.  A new timing
metric is tracked for (only) GET requests for accounts, containers,
and objects:

  proxy-server.<req_type>.GET.<status_int>.first-byte.timing

Also updated StatsD documentation in the Admin Guide to clarify that
timing metrics are sent in units of milliseconds.

Change-Id: I5bb781c06cefcb5280f4fb1112a526c029fe0c20
2013-02-13 15:58:57 -08:00
Samuel Merritt
a78b2d5f46 Fix 500 on GET of many-segment manifest.
The proxy_logging middleware was asserting that the response contained
either a Content-Length header or a Transfer-Encoding header. If not,
it would either add one (if app_iter was a list) or blow up
(otherwise). This blowing up is observable on a GET request to a
manifest object that references more than
swift.common.constraints.CONTAINER_LISTING_LIMIT segments.

If a response makes it up to eventlet.wsgi without a Content-Length
header, then a "Transfer-Encoding: chunked" header is automatically
stuffed into the response by eventlet. Therefore, it's not an error
for a response to not have a Content-Length header, and proxy_logging
should just let it happen.

Fixes bug 1078113.

Change-Id: I3751a8ae14dc68bab546f2746b61267a5115e252
2012-11-12 15:02:04 -08:00
John Dickinson
ec75d1e343 add OPTIONS to proxy_logging configs and docs
Change-Id: I77e1d7fdcf217826402beeb7d583e3c7279c416c
2012-11-06 15:13:01 -08:00
Michael Barton
5e3e9a882d local WSGI Request and Response classes
This change replaces WebOb with a mostly compatible local library,
swift.common.swob.  Subtle changes to WebOb's API over the years have been a
huge headache.  Swift doesn't even run on the current version.

There are a few incompatibilities to simplify the implementation/interface:
 * It only implements the header properties we use.  More can be easily added.
 * Casts header values to str on assignment.
 * Response classes ("HTTPNotFound") are no longer subclasses, but partials
   on Response, so things like isinstance no longer work on them.
 * Unlike newer webob versions, will never return unicode objects.

Change-Id: I76617a0903ee2286b25a821b3c935c86ff95233f
2012-09-28 14:48:48 -07:00
Darrell Bishop
4a2ae2b460 Upating proxy-server StatsD logging.
Removed many StatsD logging calls in proxy-server and added
swift-informant-style catch-all logging in the proxy-logger middleware.
Many errors previously rolled into the "proxy-server.<type>.errors"
counter will now appear broken down by response code and with timing
data at: "proxy-server.<type>.<verb>.<status>.timing".  Also, bytes
transferred (sum of in + out) will be at:
"proxy-server.<type>.<verb>.<status>.xfer".  The proxy-logging
middleware can get its StatsD config from standard vars in [DEFAULT] or
from access_log_statsd_* config vars in its config section.

Similarly to Swift Informant, request methods ("verbs") are filtered
using the new proxy-logging config var, "log_statsd_valid_http_methods"
which defaults to GET, HEAD, POST, PUT, DELETE, and COPY.  Requests with
methods not in this list use "BAD_METHOD" for <verb> in the metric name.
To avoid user error, access_log_statsd_valid_http_methods is also
accepted.

Previously, proxy-server metrics used "Account", "Container", and
"Object" for the <type>, but these are now all lowercase.

Updated the admin guide's StatsD docs to reflect the above changes and
also include the "proxy-server.<type>.handoff_count" and
"proxy-server.<type>.handoff_all_count" metrics.

The proxy server now saves off the original req.method and proxy_logging
will use this if it can (both for request logging and as the "<verb>" in
the statsd timing metric).  This fixes bug 1025433.

Removed some stale access_log_* related code in proxy/server.py.  Also
removed the BaseApplication/Application distinction as it's no longer
necessary.

Fixed up the sample config files a bit (logging lines, mostly).

Fixed typo in SAIO development guide.

Got proxy_logging.py test coverage to 100%.

Fixed proxy_logging.py for PEP8 v1.3.2.

Enhanced test.unit.FakeLogger to track more calls to enable testing
StatsD metric calls.

Change-Id: I45d94cb76450be96d66fcfab56359bdfdc3a2576
2012-08-29 16:08:30 -07:00
gholt
7923c56afa Fixed proxy logging.
It wasn't logging the full path, depending on if WebOb's
path_info_pop had been called.

Change-Id: I612d4cae7a4dc1bf5164356af329496245ad85dc
2012-08-01 00:16:12 +00:00
gholt
8b778c706a Make proxy-logging more like eventlet.posthook
The old use of Eventlet's posthook process meant that responses that
forgot to include content-length or transfer-encoding headers would
get one tacked on, if Eventlet could guess what was probably meant. I
added a bit of that logic into proxy-logging now as we saw some
errors resulting from this.

Fixes Bug #1012714

Change-Id: I671453eaf3704eab814ff12c4625ba7d749cc7ed
2012-06-13 15:11:32 +00:00
gholt
7a9c2d6ea5 Proxy logging content-length fix
Change-Id: Iad2f12b3db44378c1369481c567b3d13b9a4b75f
2012-06-01 19:31:08 +00:00
Michael Barton
7c98e7a625 Move proxy server logging to middleware.
Change-Id: I771c87207d4e1821e32c3424b341d182cc7ea7c0
2012-05-24 21:15:51 -07:00