146 Commits

Author SHA1 Message Date
Jenkins
2aee5737ab Merge "Add targeted config loading to swift-init" 2014-05-21 17:43:03 +00:00
Chuck Thier
0a122c1575 Add targeted config loading to swift-init
This allows an easier and more explicit way to tell swift-init to run on
specific servers.  For example with an SAIO, this allows you to do
something like:

swift-init object-server.1 reload

to reload just the 1st object server.  A more real world example is when
you are running separate servers for replication.  In this example you
might have an object-server/public.conf and
object-server/replication.conf.  With this change you can do something
like:

swift-init object-server.replication reload

to just reload the replication server.

DocImpact
Change-Id: I5c6046b5ee28e17dadfc5fc53d1d872d9bb8fe48
2014-05-19 14:43:50 +00:00
Brian Cline
b4c5a13664 Uses None instead of mutables for function param defaults
As seen on #1174809, changes use of mutable types as default
arguments and defaults them within the method. Otherwise, those
defaults can be unexpectedly persisted with the function between
invocations and erupt into mass hysteria on the streets.

There was indeed a test (TestSimpleClient.test_get_with_retries)
that was erroneously relying on this behavior. Since previous tests
had populated their own instantiations with a token, this test only
passed because the modified headers dict from previous tests was
being overridden. As expected, with the mutable defaults fix in
SimpleClient, this test begain to fail since it never specified any
token, yet it has always passed anyway. This change also now provides
the expected token.

Change-Id: If95f11d259008517dab511e88acfe9731e5a99b5
Related-Bug: #1174809
2014-05-10 11:15:56 +00:00
anc
1fb0709d2f Unit test for common.utils.cache_from_env
The behavior of common.utils.cache_from_env
was changed by https://review.openstack.org/#/c/89488/.
This patch adds unit test for that function.

Change-Id: If757e12990c971325f7705731ef529a7e2a9eee7
2014-04-25 15:09:15 +01:00
Greg Lange
d32dc8d49c Unify backend logging
Make account, object, and container servers construct log lines using the
same utility function so they will produce identically formatted lines.

This change reorders the fields logged for the account server.

This change also adds the "additional info" field to the two servers that
didn't log that field.  This makes the log lines identical across all 3
servers.  If people don't like that, I can take that out.  I think it makes
the documentation, parsing of the log lines, and the code a tad cleaner.

DocImpact

Change-Id: I268dc0df9dd07afa5382592a28ea37b96c6c2f44
Closes-Bug: 1280955
2014-04-07 18:38:04 +00:00
Jenkins
556667087c Merge "Fix TestGreenThreadSafeIterator test" 2014-04-01 20:39:34 +00:00
Peter Portante
5bb7603fce Mock out time and sleep to avoid races
We mock out time.time(), time.sleep() and eventlet.sleep() so that we
avoid test problems caused by exceedingly long delays during the
execution of the test.

We also make sure to convert the units used in the tests to
milliseconds for a bit more clarity.

Closes bug: 1298154

Change-Id: I803d06cbf205a02a4f7bb1e0c467d276632cd6a3
2014-03-27 23:57:36 -04:00
Peter Portante
b8f73a171d Move like unit tests together; add comments
Some simple code movement to move the utils.ratelimit_sleep() unit
tests together so that they can be viewed all at once.

We also add some comments to document the behavior of
utils.ratelimit_sleep(); small modification to max_rate parameter
checking to match intended use.

Change-Id: I3b11acfb6634d16a4b3594dba8dbc7a2d3ee8d1a
2014-03-27 15:58:13 -04:00
Greg Lange
a26b705d39 Fix TestGreenThreadSafeIterator test
Change-Id: Ic121ae5c99b4e5c5e3d1efc432b55b762d50f3fb
Closes-Bug: 1190244
2014-03-18 21:17:52 +00:00
Eamonn O'Toole
793489b80d Allow specification of object devices for audit
In object audit "once" mode we are allowing the user to specify
a sub-set of devices to audit using the "--devices" command-line
option.  The sub-set is specified as a comma-separated list.  This
patch is taken from a larger patch to enable parallel processing
in the object auditor.

We've had to modify recon so that it will work properly with this
change to "once" mode.    We've modified dump_recon_cache()
so that it will store nested dictionaries, in other words it will
store a recon cache entry such as {'key1': {'key2': {...}}}. When
the object auditor is run in "once" mode with "--devices" set the
object_auditor_stats_ALL and ZBF entries look like:
{'object_auditor_stats_ALL': {'disk1disk2..diskn': {...}}}. When
swift-recon is run, it hunts through the nested dicts to find the
appropriate entries.  The object auditor recon cache entries are set
to {} at the beginning of each audit cycle, and individual disk
entries are cleared from cache at the end of each disk's audit cycle.

DocImpact

Change-Id: Icc53dac0a8136f1b2f61d5e08baf7b4fd87c8123
2014-03-11 14:17:08 +00:00
Samuel Merritt
09ef06fd99 Convert all old-style classes to new-style
This cleanup has been slowly happening for a while; let's finish it.

Change-Id: I1561e3540d524834e0cc5bc725ab80936eae1f0e
2014-03-03 17:28:48 -08:00
Jenkins
076634e23c Merge "Fix fd leak from get_logger() in python 2.6" 2014-02-27 01:56:04 +00:00
Jenkins
9034558f0b Merge "Add secondary groups to user during privilege escalation" 2014-01-28 00:37:49 +00:00
Jenkins
9b3c86fb70 Merge "ismount should not raise exceptions" 2014-01-24 21:07:09 +00:00
David Moreau Simard
c656e18949 Add secondary groups to user during privilege escalation
setgid provides the primary group, setgroups sets the secondary
groups. Prior to this patch, we would do a setgroups with an empty
list, effectively wiping secondary groups. We now verify which
secondary groups the user is member of and escalate the privileges
accordingly.

Change-Id: I33a10edd448b3ac5aa758a8d1d70e582cf421c7d
Closes-Bug: 1269473
2014-01-23 12:43:08 -05:00
Peter Portante
ca87827db9 Use a tempfile.mkdtemp() based temporary directory
Change-Id: Ie0e8137615348b130b67323d0d2913dc5ebfd5fb
2014-01-19 16:29:45 -05:00
gholt
39b822873f ismount should not raise exceptions
The changes from using os.path.ismount to using
swift.common.utils.ismount has caused problems since the new one
raises exceptions in cases where the old one did not. Daemons have
been encountering this and exiting; servers have been 500ing instead
of 507ing in this case, changing handoff behaviors, etc.

Since the new one was specifically written and tested for this new
behavior, I left that original function as ismount_raw and made
ismount do what it did before.

If there really isn't some reason for this new behavior, I'll be glad
to get rid of ismount_raw and just keep ismount. I couldn't see any
reason for the new behavior myself.

Change-Id: I2b5b17f9ed9656cd8804a5ed568170697d0b183d
2014-01-16 08:01:10 +00:00
gholt
a3f2400cba Consolidating and standardizing x-delete-at format
Change-Id: Idc916da1c7fe1cc43a2c26f7f7ee1d4fcdd52c89
2014-01-14 15:40:35 +00:00
Jenkins
d698c21ab3 Merge "New container sync configuration option" 2014-01-14 02:40:39 +00:00
Samuel Merritt
1901719542 Move all SLO functionality to middleware
This way, with zero additional effort, SLO will support enhancements
to object storage and retrieval, such as:
 * automatic resume of GETs on broken connection (today)
 * storage policies (in the near future)
 * erasure-coded object segments (in the far future)

This also lets SLOs work with other sorts of hypothetical third-party
middleware, for example object compression or encryption.

Getting COPY to work here is sort of a hack; the proxy's object
controller now checks for "swift.copy_response_hook" in the request's
environment and feeds the GET response (the source of the new object's
data) through it. This lets a COPY of a SLO manifest actually combine
the segments instead of merely copying the manifest document.

Updated ObjectController to expect a response's app_iter to be an
iterable, not just an iterator. (PEP 333 says "When called by the
server, the application object must return an iterable yielding zero
or more strings." ObjectController was just being too strict.) This
way, SLO can re-use the same response-generation logic for GET and
COPY requests.

Added a (sort of hokey) mechanism to allow middlewares to close
incompletely-consumed app iterators without triggering a warning. SLO
does this when it realizes it's performed a ranged GET on a manifest;
it closes the iterable, removes the range, and retries the
request. Without this change, the proxy logs would get 'Client
disconnected on read' in them.

DocImpact

blueprint multi-ring-large-objects

Change-Id: Ic11662eb5c7176fbf422a6fc87a569928d6f85a1
2014-01-13 10:52:29 -08:00
gholt
f60d05686f New container sync configuration option
Summary of the new configuration option:

The cluster operators add the container_sync middleware to their
proxy pipeline and create a container-sync-realms.conf for their
cluster and copy this out to all their proxy and container servers.
This file specifies the available container sync "realms".

A container sync realm is a group of clusters with a shared key that
have agreed to provide container syncing to one another.

The end user can then set the X-Container-Sync-To value on a
container to //realm/cluster/account/container instead of the
previously required URL.

The allowed hosts list is not used with this configuration and
instead every container sync request sent is signed using the realm
key and user key.

This offers better security as source hosts can be faked much more
easily than faking per request signatures. Replaying signed requests,
assuming it could easily be done, shouldn't be an issue as the
X-Timestamp is part of the signature and so would just short-circuit
as already current or as superceded.

This also makes configuration easier for the end user, especially
with difficult networking situations where a different host might
need to be used for the container sync daemon since it's connecting
from within a cluster. With this new configuration option, the end
user just specifies the realm and cluster names and that is resolved
to the proper endpoint configured by the operator. If the operator
changes their configuration (key or endpoint), the end user does not
need to change theirs.

DocImpact

Change-Id: Ie1704990b66d0434e4991e26ed1da8b08cb05a37
2014-01-10 23:48:00 +00:00
Samuel Merritt
0ff39c14c3 Fix fd leak from get_logger() in python 2.6
Calling get_logger({}) instantiates a logging.handlers.SyslogHandler,
which opens and keeps a socket around (either /dev/log or UDP or
whatever; not important).

Under Python 2.6, all logging handlers instantiated anywhere at all
will live for the entire lifetime of the program; they get stored in
logging._handlerList and logging._handlers. Python 2.7 is very
similar, but uses weakrefs instead of strong references in those
module-level variables, so logging handlers can actually get cleaned
up prior to program exit.

The net effect is that any program that calls get_logger() more than a
fixed number of times will leak file descriptors under Python 2.6.

This commit throws encapsulation out the window and, under 2.6 only,
replaces strong references with weakrefs in logging._handlerList and
logging._handlers, thus avoiding the leak.

Change-Id: I5dc0d1619c5a4500f892b898afd9e3668ec0ee7c
2013-12-19 11:19:40 -08:00
Samuel Merritt
16204c706d Preserve tracebacks from run_in_thread
Now the traceback goes all the way down to where the exception came
from, not just down to run_in_thread. Better for debugging.

Change-Id: Iac6acb843a6ecf51ea2672a563d80fa43d731f23
2013-12-17 16:18:35 -08:00
Jenkins
34b4bf34d2 Merge "Added discoverable capabilities." 2013-11-28 00:11:35 +00:00
Michael Barton
7207926cff slightly less early quorum
The early quorum change has maybe added a little bit too much
eventual to the consistency of requests in Swift, and users can
sometimes get unexpected
results.

This change gives us a knob to turn in finding the right balance,
by adding a timeout where pending requests can finish after quorum
is achieved.

Change-Id: Ife91aaa8653e75b01313bbcf19072181739e932c
2013-11-25 21:25:55 +00:00
Jenkins
5989849512 Merge "Per device replication_lock" 2013-11-22 23:04:33 +00:00
Richard (Rick) Hawkins
2c4bf81464 Added discoverable capabilities.
Swift can now optionally be configured to allow requests to '/info',
providing information about the swift cluster.  Additionally a HMAC
signed requests to
'/info?swiftinfo_sig=<sign>&swiftinfo_expires=<expires>' can be
configured allowing privileged access to more sensitive information
not meant to be public.

DocImpact
Change-Id: I2379360fbfe3d9e9e8b25f1dc34517d199574495
Implements: blueprint capabilities
Closes-Bug: #1245694
2013-11-22 15:54:13 -06:00
gholt
c859ebf5ce Per device replication_lock
New replication_one_per_device (True by default)
that restricts incoming REPLICATION requests to
one per device, replication_currency allowing.

Also has replication_lock_timeout (15 by default)
to control how long a request will wait to obtain
a replication device lock before giving up.

This should be very useful in that you can be
assured any concurrent REPLICATION requests are
each writing to distinct devices. If you have 100
devices on a server, you can set
replication_concurrency to 100 and be confident
that, even if 100 replication requests were
executing concurrently, they'd each be writing to
separate devices. Before, all 100 could end up
writing to the same device, bringing it to a
horrible crawl.

NOTE: This is only for ssync replication. The
current default rsync replication still has the
potentially horrible behavior.

Change-Id: I36e99a3d7e100699c76db6d3a4846514537ff685
2013-11-22 21:40:29 +00:00
Samuel Merritt
b5b0b78fc7 Remove obsolete future imports
The with statement has been standard since Python 2.5, so we can get
rid of these imports.

Change-Id: I280971c3d8c01e94cc2c17cacaedcbe9d9c8a3c3
2013-11-22 12:23:58 -08:00
Michael Barton
f0c0855ec8 early quorum responses
Allow the proxy to respond to many types of requests as soon as it has a
quorum.  This can help speed up responses (without changing the results),
especially when one node is acting up.

I had to fix a few unit tests that no longer match the backend http requests
made by our proxy.

Change-Id: Ieb070dc3019e217e717b96154a7a809409bf40a5
2013-11-07 01:48:14 +00:00
Yuan Zhou
ed5101b200 Adding more unit tests for audit_location_generator
Change-Id: I40410fbbb79cea8647074f703e4675364c69d930
2013-10-19 11:40:35 +08:00
Peter Portante
9411a24ba7 Revert "Refactor common/utils methods to common/ondisk"
This reverts commit 7760f41c3ce436cb23b4b8425db3749a3da33d32

Change-Id: I95e57a2563784a8cd5e995cc826afeac0eadbe62
Signed-off-by: Peter Portante <peter.portante@redhat.com>
2013-10-07 17:18:09 -04:00
Jenkins
0b594bc3af Merge "Change OpenStack LLC to Foundation" 2013-10-07 16:09:37 +00:00
Jenkins
10bb74a872 Merge "SLOs broken for range requests" 2013-09-20 19:09:23 +00:00
ZhiQiang Fan
92ae497800 Fix unsuitable assertTrue
assertTrue accepts a parameter msg which will be printed when
assertion fails, usually msg is a str. This patch fixes unsuitable
usage of assertTrue which set msg to bool type True.

Change-Id: I731f8ea553c935eba0e112ffded16f41a5ea86c0
Fixes-Bug: #1226374
2013-09-20 23:52:56 +08:00
David Goetz
01f58d6826 SLOs broken for range requests
Change-Id: I21175a4be0cda9a8a98c425bff11c80895cd6d3e
2013-09-20 08:51:21 -07:00
ZhiQiang Fan
f72704fc82 Change OpenStack LLC to Foundation
Change-Id: I7c3df47c31759dbeb3105f8883e2688ada848d58
Closes-bug: #1214176
2013-09-20 01:02:31 +08:00
Peter Portante
7760f41c3c Refactor common/utils methods to common/ondisk
Place all the methods related to on-disk layout and / or configuration
into a new common module that can be shared by the various modules
using the same on-disk layout.

Change-Id: I27ffd4665d5115ffdde649c48a4d18e12017e6a9
Signed-off-by: Peter Portante <peter.portante@redhat.com>
2013-09-17 17:32:04 -04:00
Jenkins
de4da072aa Merge "Perform fewer stat calls when doing auditing of objects" 2013-09-09 23:04:44 +00:00
Dirk Mueller
3d36a76156 Use Python 3.x compatible except construct
except x,y: was deprected and is removed in Python 3.x.
Use "except x as y:" instead which works in any Python
version >= 2.6.

Change-Id: I7008c74b807340f3457d3a0c8bd0b83f23169d14
2013-09-07 10:50:54 +02:00
Alex Gaynor
12f95cc5a1 Perform fewer stat calls when doing auditing of objects
Each `isdir` or `exists` call performs a stat, but that info is already
available from the exception if it doesn't exist in `listdir`.

Change-Id: I831494e3dbc8fda62ab29431471566bdb8dc6d27
2013-09-05 18:57:03 -07:00
Peter Portante
be1cff4f1f Pep8 unit test modules w/ <= 10 violations (5 of 12)
Change-Id: I8e82c14ada52d44df5a31e08982ac79cd7e5c969
Signed-off-by: Peter Portante <peter.portante@redhat.com>
2013-09-01 15:12:48 -04:00
Peter Portante
c067abd21e Pep8 unit test modules for hacking and one liners (4 of 12)
Address all the "hacking" lines that are flagged, and all the modules
that just have one item flagged.

Change-Id: I372a4bdf9c7748f73e38c4fd55e5954f1afade5b
Signed-off-by: Peter Portante <peter.portante@redhat.com>
2013-09-01 15:12:39 -04:00
Yuan Zhou
da42fe01d9 Clean up utf8ness quote
Move common codes on utf8ness and quote to common/utils.py

Change-Id: I91d98a06fa94ac608119a0d70adedc6d73337c64
2013-08-29 11:32:01 +08:00
Jenkins
d2ccfa85c6 Merge "use testCase.assert instead of assert and try...except" 2013-08-23 08:45:16 +00:00
Jenkins
5c6f0015d5 Merge "Don't append %interface with ipv6 ips." 2013-08-20 11:13:58 +00:00
Fabien Boucher
fad5f25764 Use randomly named file for temporay file
Use tempfile.mkstemp to generate temporary
file to avoid collision with an existing 'test'
file in /tmp.

Change-Id: Ic2f7f64ee9826afa6f04debd763e8c7a0eb25988
Fixes: bug #1213845
2013-08-19 11:41:38 +02:00
Kun Huang
05a985366a use testCase.assert instead of assert and try...except
In unit tests, we should use: self.assertTrue or self.assertFalse
instead of 'assert xxx is True/False', and use self.assertRaises instead
of 'try ... except ...'

fixes bug #1212602

Change-Id: I25318eb59cd26a98afdce5495273e3b3266655a4
2013-08-15 17:05:07 +08:00
Chmouel Boudjnah
a0c34ed995 Don't append %interface with ipv6 ips.
- Since netifaces is appending a %interface (i.e: %eth0) at the end and
  does not make a correct ipv6 address we are removing it.
- Improve the tests of whataremyips along the way.

Closes-Bug: 1209443
Change-Id: I585e795083783009961b429607ca3f66b8d7ec30
2013-08-08 11:41:57 +02:00
Chmouel Boudjnah
64756f8d17 Use /var/run/syslog on macosx for syslog tests.
- This patch is based on zaictev review.
- Fixes bug 1206560.

Change-Id: I41f3d485df41fe443784f803b276712405fe72c6
2013-08-06 13:04:07 +02:00