6755 Commits

Author SHA1 Message Date
Alistair Coles
45884c1102 Enable per policy proxy config options
This is an alternative approach to that proposed in [1]

Adds support for optional per-policy config sections
to be added in proxy-server.conf. This is highly desirable
to allow per-policy affinity options to be set for use with
duplicated EC policies [2] and composite rings [3].

Certain options found in per-policy conf sections will
override their equivalents that may be set in the
[app:proxy-server] section. Currently the options
handled that way are:

  sorting_method
  read_affinity
  write_affinity
  write_affinity_node_count

For example:

  [proxy-server:policy:0]
  sorting_method = affinity
  read_affinity = r1=100
  write_affinity = r1
  write_affinity_node_count = 1 * replicas

The corresponding attributes of the proxy-server Application
are now available from instances of an OverrideConf object
that is obtained from Application.get_policy_options(policy).

[1] Related-Change: I9104fc789ba85ab3ab5ccd34096125b482821389
[2] Related-Change: Idd155401982a2c48110c30b480966a863f6bd305
[3] Related-Change: I0d8928b55020592f8e75321d1f7678688301d797

Co-Authored-By: Kota Tsuyuzaki <tsuyuzaki.kota@lab.ntt.co.jp>
Change-Id: I3f718f425f525baa80045ba067950c752bcaaefc
2017-05-23 20:22:30 +01:00
Tim Burke
1b991803e8 Clean up how PatchPolicies works
We've got these lovely __enter__ and __exit__ methods; let's use them!

Note that this also changes how we patch classes' setUp methods so we
don't set self._orig_POLICIES when the class is already patched.  I
hope this may fix some sporadic failures that include tracebacks
that look like

  proxy ERROR: ERROR 500 Traceback (most recent call last):
    File ".../swift/obj/server.py", line 1105, in __call__
      res = getattr(self, req.method)(req)
    File ".../swift/common/utils.py", line 1626, in _timing_stats
      resp = func(ctrl, *args, **kwargs)
    File ".../swift/obj/server.py", line 880, in GET
      policy=policy, frag_prefs=frag_prefs)
    File ".../swift/obj/server.py", line 211, in get_diskfile
      return self._diskfile_router[policy].get_diskfile(
    File ".../swift/obj/diskfile.py", line 555, in __getitem__
      return self.policy_to_manager[policy]
  KeyError: ECStoragePolicy(...)

... and try to unpatch more gracefully with TestCase.addCleanup

Change-Id: Iaa3d42ec21758b0707155878a645e665aa36696c
2017-05-19 17:59:36 -07:00
Jenkins
a2e020c52b Merge "Add read and write affinity options to deployment guide" 2017-05-19 19:05:33 +00:00
Christian Schwede
5eeaa95440 Make mount_check option usable in containerized environments
The ismount_raw method does not work inside containers if disks are
mounted on the hostsystem and only mountpoints are exposed inside the
containers. In this case the inode and device checks fail, making this
option unusable.

Mounting devices into the containers would solve this. However, this
would require that all processes that require access to a device are
running inside the same container, which counteracts the container
concept.

This patch adds the possiblity to place stubfiles named ".ismount" into
the root directory of any device, and Swift assumes a given device to be
mounted if that file exists. This should be transparent to existing
clusters.

Change-Id: I9d9fc0a4447a8c5dd39ca60b274c119af6b4c28f
2017-05-19 12:16:53 +02:00
Alistair Coles
f02ec4de81 Add read and write affinity options to deployment guide
Add entries for these options in the deployment guide and
make the text in proxy-server.conf-sample and man page
consistent.

Change-Id: I5854ddb3e5864ddbeaf9ac2c930bfafdb47517c3
2017-05-18 10:42:44 -07:00
Jenkins
9089e44c0b Merge "Add Composite Ring Functionality" 2017-05-18 10:18:31 +00:00
Kota Tsuyuzaki
4dc985a1fa Small minor fixes for composite ring functionality
This is a follow up for https://review.openstack.org/#/c/441921
all of this patch is for minor fixes, I found in my self-review.

Change-Id: Ib3a1dc983c3da69dea592114e25a5047ec91a2b9
2017-05-18 01:48:14 -07:00
Tim Burke
582af7cd9d name_check: better test maximum_length
Previously, we were testing that a 254 (!?) character name would be valid
when the maximum configured is 500. Now we'll test that 500 character
names are valid.

While we're at it, stop patching self.test_check. It was unnecessary,
and we were doing it badly.

Change-Id: Ia604fa7b809a97fbce176c82606af73cdb92828c
2017-05-16 17:59:52 -07:00
Kota Tsuyuzaki
d40031b46f Add Composite Ring Functionality
* Adds a composite_builder module which provides the functionality to
  build a composite ring from a number of component ring builders.

* Add id to RingBuilder to differentiate rings in composite.
  A RingBuilder now gets a UUID when it is saved to file if
  it does not already have one. A RingBuilder loaded from
  file does NOT get a UUID assigned unless it was previously persisted in
  the file. This forces users to explicitly assign an id to
  existing ring builders by saving the state back to file.

  The UUID is included in first line of the output from:

    swift-ring-builder <builder-file>

Background:

This is another implementation for Composite Ring [1]
to enable better dispersion for global erasure coded cluster.

The most significant difference from the related-change [1] is that this
solution attempts to solve the problem as an offline tool rather than
dynamic compositing on the running servers. Due to the change, we gain
advantages such as:

- Less code and being simple
- No complex state validation on the running server
- Easy deployments with an offline tool

This patch does not provide a command line utility for managing
composite rings. The interface for such a tool is still under
discussion; this patch provides the enabling functionality first.

Co-Authored-By: Clay Gerrard <clay.gerrard@gmail.com>
Co-Authored-By: Alistair Coles <alistairncoles@gmail.com>

[1] Related-Change: I80ef36d3ac4d4b7c97a1d034b7fc8e0dc2214d16
Change-Id: I0d8928b55020592f8e75321d1f7678688301d797
2017-05-15 16:42:00 -07:00
Jenkins
6e893e2288 Merge "Drop unnecessary dereferencing" 2017-05-12 21:26:58 +00:00
Jenkins
4a19917827 Merge "Open-code eventlet.listen()" 2017-05-12 16:46:28 +00:00
Jenkins
145cfc3174 Merge "Fix domain_remap when obj starts/ends with slash" 2017-05-12 15:47:20 +00:00
Pete Zaitcev
cd2d359b02 Drop unnecessary dereferencing
The patch that introduced this (with my own help, no less),
also pasted these in tests, but someone else has already
cleaned that up.

Change-Id: I87c0a110831b5b5f75cb6fde1badec338f2150a9
2017-05-11 18:11:55 -06:00
Daisuke Morita
843184f3fe Sync metadata in 'rsync_then_merge' in db_replicator
In previous 'rsync_then_merge' remote objects are merged with
rsync'ed local objects, but remote metadata is not merged with local
one. Account/Container replicator sometimes uses rsync for db sync if
there is a big difference of record history in db files between 'local'
and 'remote' servers. If replicator needs to rsync local db to remote
but metadata in local db is older, older info of metadata can be
distributed then some metadata values can be missing or go back to older.

This patch fixes this problem by merging 'remote' metadata with
rsync'ed local db file.

Closes-Bug: #1570118

Change-Id: Icdf0a936fc456c5462471938cbc365bd012b05d4
2017-05-11 17:39:16 -04:00
Jenkins
1d09a02481 Merge "Remove links for EOLed releases" 2017-05-11 14:16:49 +00:00
Jenkins
7fd41f3db4 Merge "Update multi-node install links" 2017-05-11 14:01:20 +00:00
Tim Burke
3981e1ee8a Remove links for EOLed releases
Change-Id: If7e8526edf18b02474ba272451b9b4212558e03c
2017-05-11 13:57:10 +00:00
Romain LE DISEZ
107ba79770 Rewrite redirection in cname_lookup & domain_remap
cname_lookup and domain_remap are currently not catching redirections
(eg: staticweb). This behavior makes the domain to change when a call
through cname_lookup and domain_remap end up being redirected. Example:
commit fixes it.
 - original request: http://mysite.com/subdir
 - redirected:  http://cont.acct.storage.domain.com/v1/AUTH_acct/cont/subdir/
 - expected: http://mysite.com/subdir/

This patch is fixing this.

Closes-Bug: #1190625
Co-Authored-By: Tim Burke <tim.burke@gmail.com>
Change-Id: I67f642b8b070bc21e7760477d0a1e3b902ba7896
2017-05-11 09:46:29 -04:00
Clay Gerrard
37f6f25283 Update multi-node install links
... as is useful to do from time to time

Change-Id: I165899445080fa3a8e6dc624ab5a13680b819a73
2017-05-11 09:13:02 -04:00
Romain LE DISEZ
6db12b87ff Fix domain_remap when obj starts/ends with slash
domain_remap strip all starting/ending slashes. This behavior does not
allow to access objects starting or ending with slash. It is also
impacting staticweb middleware as staticweb tries to redirect
pseudo-directory to an URL with an ending slash, but as domain_remap
strip it, it goes to an infinite loop.

With this commit, the path of the request is passed as-is when
reconstructing the new request path. Example
http://www.example.com//obj/ was previously rewritten to
http://storage.example.com/v1/AUTH_abc/container/obj. It is now
rewritten to http://storage.example.com/v1/AUTH_abc/container//obj/

Closes-Bug: #1682293
Co-Authored-By: Christian Schwede <cschwede@redhat.com>
Change-Id: I1ef6b8752183d27103a3b0e720edcb4ce06fb837
2017-05-11 08:47:23 -04:00
Pete Zaitcev
5dfc3a75fb Open-code eventlet.listen()
Recently out gate started blowing up intermittently with a strange
case of ports mixed up. Sometimes a functional tests tries to
authorize on a port that's clearly an object server port, and
the like. As it turns out, eventlet developers added an unavoidable
SO_REUSEPORT into listen(), which makes listen(("localhost",0)
to reuse ports.

There's an issue about it:
 https://github.com/eventlet/eventlet/issues/411

This patch is working around the problem while eventlet people
consider the issue.

Change-Id: I67522909f96495a6a30e1acdb79835dce2189549
2017-05-11 01:39:14 -06:00
Jenkins
cd712cd144 Merge "Trivial fix typo and PEP 8 coding style violation" 2017-05-10 20:10:05 +00:00
Jenkins
1f36582efb Merge "Fix unit tests on i386 and other archs" 2017-05-10 19:58:45 +00:00
Jenkins
2abffb99b9 Merge "Fix sporadic failure in TestObjectController.test_container_update_async" 2017-05-10 14:51:35 +00:00
Ngo Quoc Cuong
cd50160191 Trivial fix typo and PEP 8 coding style violation
telemtry -> telemetry
PEP 8: line too long (81 > 79 characters)

Change-Id: I2f70f64a3a2cbf35e4a5250e1099f176670cb31f
2017-05-09 08:17:56 +07:00
Jenkins
7ebb2cdef7 Merge "Trivial fix typo while reading doc" 2017-05-06 10:17:18 +00:00
Jenkins
30898435b1 Merge "Stop including Connection header in EC GET responses" 2017-05-05 22:12:05 +00:00
Jenkins
7bbb80884d Merge "Add message to account-creation assertion" 2017-05-05 21:01:43 +00:00
Ngo Quoc Cuong
e23f8d3160 Trivial fix typo while reading doc
Change-Id: I9d96dd4464a086e508fbf18057b4f3e90c82c916
2017-05-05 23:06:14 +07:00
Tim Burke
50357de575 Fix sporadic failure in TestObjectController.test_container_update_async
Change-Id: Ie4d58626ebe97049703802a43c669cc78cf60f8b
Related-Change: I15f36e191cfe3ee6c82b4be56e8618ec0230e328
Closes-Bug: #1589994
2017-05-05 00:11:39 +00:00
Jenkins
4915a3a3f6 Merge "Remove the unused import code" 2017-05-04 20:33:28 +00:00
Tim Burke
4c8239503a Add message to account-creation assertion
We've seen some failures in the gate like

    ==============================
    Failed 1 tests - output below:
    ==============================

    setUpModule (test.functional.test_account)
    ------------------------------------------

    Captured traceback:
    ~~~~~~~~~~~~~~~~~~~
        Traceback (most recent call last):
          File "test/functional/test_account.py", line 33, in setUpModule
            tf.setup_package()
          File "test/functional/__init__.py", line 716, in setup_package
            mem_object_server if in_mem_obj else object_server))
          File "test/functional/__init__.py", line 621, in in_process_setup
            create_account(AUTH_test)
          File "test/functional/__init__.py", line 619, in create_account
            assert(resp.status == 201)
        AssertionError

...which aren't terribly useful in figuring out what went wrong.

Change-Id: I3cd31bb480dc8508828fe21416bfae33bc0985b7
2017-05-04 17:48:26 +00:00
Jenkins
dad1951ea8 Merge "Trivial fix for decrypter docstrings" 2017-05-04 13:45:03 +00:00
Alistair Coles
511ac2ee60 Use setUpModule instead of setup for module level unit test setup
Module setup() and teardown() functions are found by nosetests [1] but
unittests expects setUpModule() and tearDownModule() [2]. The latter
function names are also found by nosetests, so using those function
names enables the test module to be run with either nosetests or
unittest.

Although the tox test envs and .unittests script use nosetests, this
change allows the convenience of using unittest, for example when it
is the default test runner in a development environment such as
PyCharm.

This change also makes it unnecessary to explicitly call the setup()
and teardown() functions when executing the module directly.

[1] http://nose.readthedocs.io/en/latest/writing_tests.html#test-modules
[2] https://docs.python.org/2/library/unittest.html#setupmodule-and-teardownmodule

Change-Id: Ib2e5470a339af1f937b25d643b64356e8848ed36
2017-05-04 12:47:17 +01:00
Jenkins
dd3bc8fe61 Merge "Move EC-specific unit test to EC Test class" 2017-05-03 23:20:36 +00:00
Jenkins
33a422af9f Merge "Fix (un)patch_policies" 2017-05-03 21:11:39 +00:00
Jenkins
0e58bfffac Merge "Trivial fix warnings in docstring" 2017-05-03 18:31:11 +00:00
Ngo Quoc Cuong
172c4de31d Trivial fix warnings in docstring
Single quoted docstring
Params and docstring are inconsistent

Change-Id: Ie41bd2960280491f0a5fbd55c6a1aabb328099b8
2017-05-03 18:30:14 +07:00
Alistair Coles
88ca232e52 Trivial fix for decrypter docstrings
Fix wrong param descriptions in decrypter.py
Fix missing param in base.py

Change-Id: I07fdfe2e7193afa4ee6b88a10f4ba58495b509b3
2017-05-03 11:41:14 +01:00
Jenkins
4e61735e53 Merge "Use LogRecord.msg instead of LogRecord.message in tests" 2017-05-03 10:36:02 +00:00
Tim Burke
75290ec6ec Fix sporadic failures in test_reconstructor.py
We don't know the order in which connections will be made, so grab the
ip/port/dev from the mocked conn's request log.

Change-Id: I3b4486c99ad85173d5027b46e1c0613202d0f75a
2017-05-02 14:00:34 -07:00
Jenkins
d7a6d6e1e9 Merge "Do not sync suffixes when remote rejects reconstructor revert" 2017-05-01 20:38:07 +00:00
Alistair Coles
6c320b2908 Stop including Connection header in EC GET responses
Currently, EC GET responses from proxy to clients, unlike any other
response, include a "Connection: close" header. If the client has sent
a "Connection: keep-alive" header then eventlet.wsgi appends this to
the client response, so clients can receive a response with both
headers:

Connection: close
Connection: keep-alive

This patch fixes the proxy EC GET path to remove any Connection header
from it's response, but does not change the behaviour of eventlet.wsgi
with respect to returning any client provided 'Connection: keep-alive'
header.

Change-Id: I43cd27c978edb4a1a587f031dbbee26e9acdc920
Co-Authored-By: Matthew Oliver <matt@oliver.net.au>
Closes-Bug:  #1680731
2017-05-01 18:21:18 +01:00
lijunbo
96bbd06134 Remove the unused import code
Remove the unused import in ssync_receiver.py

Change-Id: I81ef107201a79446f07e87ee04758c2bf251ebda
2017-05-01 18:43:03 +08:00
Jenkins
4f3ce4db31 Merge "Fix install guide filter:authtoken config example" 2017-05-01 10:17:58 +00:00
Alistair Coles
7a9269bca3 Fix unit test failing when swift.conf has default policy index >10
In unit/container/test_backend.py test_policy_stat_tracking in
classes TestContainerBroker[BeforeMetadata|BeforeSPI|BeforeXSync]
fails if the default policy in /etc/swift/swift.conf has an index >10.

Those classes monkey patch the container broker to pre-storage-policy
index behaviour, so that it's policy index will always be 0. The test
fails with a KeyError when asserting that the broker should have stats
for the POLICIES.default index even when no object have been PUT with
that policy index. When the default policy in swift.conf has index
>10, that is neither the broker's policy index (0) nor the policy
index of any other object that has been PUT during the test.

The test need a patch_policies decorator to remove the coupling with
swift.conf policies. However, the assertion that the broker has stats
for it's policy index even when no objects were PUT to that index is
then extremely unlikely to ever be tested, because the broker's
default policy index of 0 is very likely to have used for a PUT
object. So this patch also repeats that assertion before any object
have been PUT

Closes-Bug: #1687029
Change-Id: I8b3678dac83f7329d835059c9973b994bc975a33
2017-05-01 09:24:00 +01:00
Tim Burke
387ce13aa1 Use LogRecord.msg instead of LogRecord.message in tests
From the docs for LogRecord.message [1],

> This is set when Formatter.format() is invoked.

Apparently we may find ourselves in a situation [2] where that never
happens? Really weird that it failed *midway* through the test though;
maybe some concurrent test removed all formatters?

ERROR: test_known_bad_ec_config
(test.unit.common.test_storage_policy.TestStoragePolicies)
----------------------------------------------------------------------
Traceback (most recent call last):
  File ".../mock/mock.py", line 1305, in patched
    return func(*args, **keywargs)
  File ".../test/unit/common/test_storage_policy.py", line 688, in test_known_bad_ec_config
    self.assertIn(msg, records[0].message)
AttributeError: 'LogRecord' object has no attribute 'message'

[1] https://docs.python.org/2/library/logging.html#logrecord-attributes
[2] http://logs.openstack.org/59/460359/1/check/gate-swift-tox-xfs-tmp-py27-ubuntu-xenial/5ecc2cb/console.html#_2017-04-27_01_06_43_346096
Change-Id: I8f5ac0ec1195a233f14edc0126de1d1cea7a6e2f
2017-04-28 15:56:25 -07:00
Colleen Murphy
93ca16c558 Fix install guide filter:authtoken config example
The name of the default domain in keystone is 'Default', not 'default',
which is its ID. If a user copy and pastes the user_domain_name and
project_domain_name settings from example [filter:authtoken] section
in the install guide, the first time they run 'swift stat' they will
meet a 401 error because keystone is trying to look up domains by name
rather than ID. This patch corrects the docs so that they are
copy-and-paste-proof, and also updates the keystone user creation
example to demonstrate the correct domain ID.

Change-Id: Ic595c2923b71d1c2ff2b4c9a773ea7742fdd029b
2017-04-28 15:05:45 +02:00
Jenkins
e1b74c83c4 Merge "Fix sporadic failure in TestAccountController unit test" 2017-04-28 03:19:26 +00:00
Tim Burke
85d6cd30be Add Timestamp.now() helper
Often, we want the current timestamp. May as well improve the ergonomics
a bit and provide a class method for it.

Change-Id: I3581c635c094a8c4339e9b770331a03eab704074
2017-04-27 14:19:00 -07:00