3988 Commits

Author SHA1 Message Date
Tim Burke
beb014b0b1 Read-only middleware fixups
- Expose cluster-wide read-only status in /info
- Use a set instead of list for write_methods
- Provide a more explicit response when returning 405
- Consider self.read_only in account_read_only
- Use return_values instead of callables for more mocks

Change-Id: I45387067a69919706800df3a8ca12ae8f5d16d90
2018-06-11 10:05:49 -07:00
Zuul
c01c43d982 Merge "Adds read_only middleware" 2018-06-07 06:49:26 +00:00
Zuul
720aa6961a Merge "Update SERVER_ADDR/SERVER_PORT from PROXY protocol" 2018-06-06 08:48:38 +00:00
Zuul
ba5c13e9dd Merge "Add assertion to test_consolidate_hashes_raises_exception" 2018-06-05 18:03:48 +00:00
Zuul
46443b7fbf Merge "Make final stats dump after reconstructor runs once" 2018-06-05 10:15:59 +00:00
Zuul
ec066392b5 Merge "Make If-None-Match:* work properly with 0-byte PUTs" 2018-06-05 02:45:06 +00:00
Samuel Merritt
ecf47553b5 Make final stats dump after reconstructor runs once
When running in multiprocess mode, the object reconstructor would
periodically aggregate its workers' recon data into a single recon
measurement. However, at the end of the run, all that was left in
recon was the last periodic measurement; any work that took place
after that point was not recored in the aggregate. However, it was
recorded in the per-disk stats that the worker processes emitted.

This commit adds a final recon aggregation after the worker processes
have finished.

Change-Id: Ia6a3a931e9e7a23824765b2ab111a5492e509be8
2018-06-04 15:24:45 -07:00
Zuul
84f2bfcb2e Merge "Make multiprocess reconstructor's logs more readable." 2018-06-04 16:19:24 +00:00
Zuul
2d3ceeda28 Merge "Log updater stats once per pass, not per policy" 2018-06-04 15:40:25 +00:00
Alistair Coles
e748ef4637 Verify diff stat is unchanged when syncing only shard ranges
Add test assertions to verify that the related change fixes usync diff
stats being erroneously incremented as a side-effect of syncing shard
ranges when the object tables are in sync.

Related-Change: I2630bb127841837b35e7786b59895fa50090719b
Change-Id: Idffe93c63d16e74ea9ca42b33a636c0c0d9e35b5
2018-06-01 08:49:52 +01:00
Zuul
02a2788438 Merge "Fix suffix-byte-range responses for zero-byte EC objects." 2018-06-01 00:07:56 +00:00
Zuul
7f970597ec Merge "Use X-Timestamp when checking object expiration" 2018-05-31 23:55:59 +00:00
Samuel Merritt
47aff724bb Log updater stats once per pass, not per policy
The object updater emits a log line saying "Object update sweep
completed on <disk> in <time>: <lots-of-stats>" after finishing each
storage policy's async pendings. That's not right; an update sweep is
completed on a device when you've looked at all the async pendings on
the device.

This commit moves the "sweep completed" message so it's once per
device, not per policy.

Change-Id: Ibb5f02a18ac431da230afe30c556a756f60d1680
2018-05-30 14:35:21 -07:00
Zuul
56aeb20f98 Merge "container-updater: log LockTimeout exceptions at INFO, not ERROR" 2018-05-30 18:14:54 +00:00
Zuul
c03701d7b7 Merge "Remove unhelpful log message in copy middleware" 2018-05-30 05:19:03 +00:00
Zuul
a15f55b1c9 Merge "Catch and log errors from process_container, then keep updating" 2018-05-30 05:00:42 +00:00
Greg Lange
5d601b78f3 Adds read_only middleware
This patch adds a read_only middleware to swift. It gives the ability
to make an entire cluster or individual accounts read only.
When a cluster or an account is in read only mode, requests that would
result in writes to the cluser are not allowed.

DocImpact

Change-Id: I7e0743aecd60b171bbcefcc8b6e1f3fd4cef2478
2018-05-30 03:26:36 +00:00
Samuel Merritt
a954f59f4c container-updater: log LockTimeout exceptions at INFO, not ERROR
Lock timeouts happen, especially on very busy containers. It's not
worth a stack trace, and it's not an error. Now we still log the
lock timeout, but at INFO level and without a stack trace.

Change-Id: Ia202c876fb726f9ae6040d875a83105dd975539b
2018-05-29 17:38:19 -07:00
Samuel Merritt
553bef0d1d Remove unhelpful log message in copy middleware
We probably don't need an extra INFO-level message every time a user
makes a PUT request with X-Copy-From set. It's still in the proxy's
access logs.

Change-Id: I32ce8ff16cb296dd5acef07202a59bc5125111c1
2018-05-29 16:59:14 -07:00
Zuul
e7e016267c Merge "Clarify that archive location headers should be URL-encoded" 2018-05-29 22:17:31 +00:00
Zuul
ffa9965b37 Merge "Fix versioned writes error with url-encoded object name" 2018-05-29 22:06:25 +00:00
Zuul
2208b1b618 Merge "catch lock fail exception in container updater" 2018-05-29 21:53:14 +00:00
Tim Burke
773b633118 Change default sharding threshold to 1,000,000 objects
...instead of 10,000,000. The sample configs were already using one
million, all of our testing with non-SAIO containers was done with
one million, and the resulting container DBs were around 100MB which
seems like a comfortable size. Pretty sure this was just a typo during
some code cleanup.

Change-Id: Icd31f9d8efaac2d5dc0f021cad550687859558b9
2018-05-29 10:48:51 -07:00
Tim Burke
31623f740b Catch and log errors from process_container, then keep updating
Previously, we'd bomb out hard, and you'd get no more container updates.

Change-Id: I0cea6018269d172bc758eec6348329d1f65de028
Related-Bug: 1400939
2018-05-29 10:42:31 -07:00
Hu Bing
4189a117d2 catch lock fail exception in container updater
in process of container update, when locking one container failed,
container updater stops with LockTimeout exception.

it's better for updater server to continue processing
other containers, partitions instead of stop updating.

this path is to catch timeout exception and log it,
then continue processing other containers and partitions.

Closes-bug: #1400939

Change-Id: I42adec07d980be22044a5d4ef6771318a3eed168
2018-05-29 10:42:31 -07:00
Zuul
4518d95b6f Merge "Remove un-used stub" 2018-05-26 06:53:40 +00:00
Zuul
eafe6e63bf Merge "Always pass capitalize_response_headers=False to eventlet.wsgi.server()" 2018-05-25 21:30:35 +00:00
Zuul
8bd68ec299 Merge "Add support for PROXY protocol v1 (only)" 2018-05-25 21:30:34 +00:00
Tim Burke
7b5c30dec0 Update SERVER_ADDR/SERVER_PORT from PROXY protocol
Also take a reasonable guess as to whether HTTPS/wsgi.url_scheme ought to be updated.

Change-Id: Iada8a1f4921f07986e6399bc1279e9a602117b1c
2018-05-25 14:28:08 -07:00
Zuul
e8ab5c5012 Merge "Fix SLO delete for accounts with non-ASCII names." 2018-05-24 22:10:24 +00:00
Clay Gerrard
71b39e4c2d Remove un-used stub
The mock call got pulled out in the related change.

Change-Id: Ife1e452fa34026ac934e88a05708cdc5978215e1
Related-Change-Id: Id089e29e7ecfc8cec79c520f604aa01bdae0dcf0
2018-05-24 13:17:51 -07:00
Tim Burke
fbb8d7ebb5 Clarify that archive location headers should be URL-encoded
Fix up function tests to actually *do* that quoting, and fix
_listing_pages_iter to respect that.

Change-Id: I1554042510819ea878b4c70417721944115e17f4
Related-Bug: 1229142
Related-Change: I425440f76b8328f8e119d390bfa4c7022181e89e
Related-Bug: 1755554
Related-Change: Ibcd90cc633c68973929ee5249c6598c22b342e3e
2018-05-24 13:03:35 -07:00
Samuel Merritt
693d9a6570 Always pass capitalize_response_headers=False to eventlet.wsgi.server()
For a while, this was conditional because we supported old Eventlet
versions that didn't have this keyword arg. Now, we require new-enough
Eventlet that it's always available, so let's get rid of the
conditional crud.

The flag was introduced in Eventlet 0.15, and we require >= 0.17.4.

Change-Id: Id089e29e7ecfc8cec79c520f604aa01bdae0dcf0
2018-05-23 18:15:57 -07:00
Darrell Bishop
661838d968 Add support for PROXY protocol v1 (only)
...to the proxy-server.

The point is to allow the Swift proxy server to log accurate
client IP addresses when there is a proxy or SSL-terminator between the
client and the Swift proxy server.  Example servers supporting this
PROXY protocol:
  stud (v1 only)
  stunnel
  haproxy
  hitch (v2 only)
  varnish

See http://www.haproxy.org/download/1.7/doc/proxy-protocol.txt

The feature is enabled by adding this to your proxy config file:

  [app:proxy-server]
  use = egg:swift#proxy
  ...
  require_proxy_protocol = true

The protocol specification states:

  The receiver MUST be configured to only receive the protocol
  described in this specification and MUST not try to guess
  whether the protocol header is present or not.

so valid deployments are:

  1) require_proxy_protocol = false  (or missing; default is false)
     and NOT behind a proxy that adds or proxies existing PROXY lines.
  2) require_proxy_protocol = true
     and IS behind a proxy that adds or proxies existing PROXY lines.

Specifically, in the default configuration, one cannot send the swift
proxy PROXY lines (no change from before this patch).  When this
feature is enabled, one _must_ send PROXY lines.

Change-Id: Icb88902f0a89b8d980c860be032d5e822845d03a
2018-05-23 18:10:40 -07:00
Zuul
8403ca3915 Merge "Let make_db_file_path accept epoch=None" 2018-05-23 23:40:59 +00:00
Timur Alperovich
0aad95005d Fix SLO delete for accounts with non-ASCII names.
If an account contains non-ASCII characters, currently SLO delete code
will fail, as get_slo_segments() method receives a unicode object, but
UTF-8 encoded account name. Attempting to concatenate the strings fails
with a UnicodeError, as it tries to use the ASCII codec to decode the
UTF-8 encoded account name.

This patch allows accounts with non-ASCII characters in their names to
delete SLOs.

Change-Id: I619d41e62c16b25bd5f58d300a3dc71aa4dc75c2
2018-05-23 16:19:50 -07:00
Zuul
7de310b72a Merge "Add unit tests for replicator sync_shard_ranges" 2018-05-23 18:42:48 +00:00
Zuul
9d2a1a1d14 Merge "Make the decision between primary/handoff sets more obvious" 2018-05-23 14:16:24 +00:00
Zuul
c16e459a52 Merge "Use maybe_get more" 2018-05-23 12:28:27 +00:00
Zuul
334ffbaae1 Merge "Add a helper context for optional connection args" 2018-05-23 12:01:33 +00:00
Alistair Coles
e4045fb475 Add unit tests for replicator sync_shard_ranges
Related-Change: Ie4d2816259e6c25c346976e181fb9d350f947190

Change-Id: Icd558c1f92c24724a76931f1d281a9a20122b683
2018-05-23 09:57:41 +01:00
Samuel Merritt
7a7677868d Use X-Timestamp when checking object expiration
In the object server's PUT, POST, and DELETE handlers, we use the
request's X-Timestamp value for checking object expiration. In the GET
and HEAD handlers, we use it if present, but default to the current
time. That way, one can still use curl to make direct object GET or
HEAD requests as before.

If one object server's clock is ahead of the proxy server's clock for
some reason, and a client makes a POST request to update X-Delete-At,
then the skewed-time object server may refuse the new X-Delete-At
value.

In a cluster where two of the three replicas for an object live on the
same time-skewed node, this can result in confusing behavior for
clients. A client can make a POST request to update X-Delete-At,
receive a 400, and then discover later that the X-Delete-At value was
updated anyway, since one object server accepted the POST and
replication spread the new metadata around.

DELETE is somewhat less confusing. The client might get a spurious 404
in the above case, but the object will still be removed.

For PUT, an object server with a slow clock might refuse to overwrite
an object with an "older" one because it believes the on-disk object
is newer than the current time.

Change-Id: I10c28f97d4c6aca1d64bef3b93506cfbb50ade30
2018-05-22 16:42:53 -07:00
Zuul
c3574d06bb Merge "Improve building listings from shards" 2018-05-22 23:22:04 +00:00
Clay Gerrard
6714af8042 Use maybe_get more
Some suggestions in the review of the related change:

 * use maybe_get in another obvious place
 * make maybe_gets test assertions stronger

Related-Change-Id: Ifd54d76ab1a5a9d82848f3cae89c3e53134aa129

Change-Id: I751f1086d885c18d938f18e8afe1dd0e9c0c57e5
2018-05-22 15:03:50 -07:00
Clay Gerrard
2e321d94ed Add a helper context for optional connection args
We refactor a bunch of methods to support re-using an open connection
when available.  There's some code in the connection manager to support
nesting connections to avoid deadlocks when we call a method that can
open a connection while we already have a connection checked out - but
it might be better in the long run if we just got better at passing open
connections around whenever possible.

Add a helper method on the base db broker class to make it easier to
write methods that can optionally take an existing connection.

Change-Id: Ifd54d76ab1a5a9d82848f3cae89c3e53134aa129
2018-05-22 14:17:13 -07:00
Tim Burke
4af57dbc65 Let make_db_file_path accept epoch=None
...in which case it should strip the epoch if the original path had one.

Change-Id: I8739a474c56c0f2376a276d2691c84448cb9c647
2018-05-22 13:49:17 -07:00
Zuul
ffd640565f Merge "Test rsync error log truncation" 2018-05-22 19:54:58 +00:00
Zuul
60a46530d3 Merge "Avoid premature shrinking in sharder probe test" 2018-05-22 19:54:57 +00:00
Tim Burke
8c386fff40 Make the decision between primary/handoff sets more obvious
Change-Id: I419de59df3317d67c594fe768f5696de24148280
2018-05-22 12:12:42 -07:00
Kota Tsuyuzaki
0e3e7b9b09 Fix versioned writes error with url-encoded object name
With url encoded object name like '%25ff' that can be url-encoded
value after decoded can cause 412 Precondition Failed. And more,
that can do nothing (no versioned object creation) even it returns
a successful response.

The root causes are in versioned_writes middleware as follows:

A. unnecessary unquote in object_request method
B. incorrect use of make_pre_authed_request that takes 'quoted'
   path in the args. That is described at [1] explicitely.

This patch resolved those 2 bugs at once, and then, now we can create
%25ff versioned object reported in the launchpad with this patch.

Perhaps, more tests would be nice to have. This patch added a few
test cases on that.

1: https://github.com/openstack/swift/blob/master/swift/common/wsgi.py#L1174

Note that make_subrequest and its caller should have *quoted* path but
make_env should *NOT*. That might make us confused.

Closes-Bug: #1755554

Change-Id: Ibcd90cc633c68973929ee5249c6598c22b342e3e
2018-05-23 04:07:32 +09:00