210 Commits

Author SHA1 Message Date
Alistair Coles
7b706926a8 Fix setup of manifest responses in SLO tests
The swift_bytes param is removed from the content-type
in the proxy object controller, so the SLO unit tests should
not be registering GET responses with FakeSwift that have
swift_bytes appended to the content-type.

Nor should submanifest segment dicts have swift_bytes appended to
their content-type values.

Also adds a test for the object controller and container server
handling of SLO swift_bytes.

Change-Id: Icf9bd87eee25002c8d9728b16e60c8347060f320
2016-05-23 17:26:28 +01:00
Shashirekha Gundur
cf48e75c25 change default ports for servers
Changing the recommended ports for Swift services
from ports 6000-6002 to unused ports 6200-6202;
so they do not conflict with X-Windows or other services.

Updated SAIO docs.

DocImpact
Closes-Bug: #1521339
Change-Id: Ie1c778b159792c8e259e2a54cb86051686ac9d18
2016-04-29 14:47:38 -04:00
Jenkins
60c127575b Merge "swift-[account|container]-info when disk is full" 2016-04-22 17:31:09 +00:00
Jenkins
760dcfd53d Merge "Require account/container metadata be UTF-8" 2016-04-20 19:30:22 +00:00
oshritf
c96d5c671d Per container stat. report
In addition to the container sync stat. report, keeping per container
statistics allows administrator with more control over bytes
transfered over a specific time per user account: The per container stats
are crucial for billing purposes and provides the operator a 'progress
bar' equivalent on the container's replication status.

Change-Id: Ia8abcdaf53e466e8d60a957c76e32c2b2c5dc3fa
2016-04-14 21:37:59 +03:00
Jenkins
f227072974 Merge "Correctly handle keys starting with the delimiter." 2016-04-01 02:02:44 +00:00
Janie Richling
e97c4f794d swift-[account|container]-info when disk is full
Extended the use of the DatabaseBroker "stale_reads_ok" flag to the
AccountBroker and ContainerBroker.  Now checks for an sqlite3 error
from the _commit_puts call that processes the pending files.

If this error is raised, then the stale_reads_ok flag will be checked
to determine how to proceed as opposed to simply raising.

The first time that print_info is attempted, the flag will be
false, but swift-[account|container]-info will check for the
raised exception.  If it was raised, then a warning is reported
that the data may be stale, and another attempt will be
made using the stale_reads_ok=True flag.

Change-Id: I761526eef62327888c865d87a9caafa3e7eabab6
Closes-Bug: 1531302
2016-03-24 20:11:24 -05:00
OSHRITF
125d18e0ff Container-Sync to perform HEAD before PUT object on remote
This change adds a remote HEAD object request before each call to
sync_row.
Currently, container-sync-row attempts to replicate the object
(using PUT) regardless of the existance of the object on the remote side,
thus causing each object to be transferred on the wire several times
(depending on the replication factor)

An alternative to HEAD is to do a conditional PUT (using, 100-continue).
However, this change is more involved and requires upgrade of both the
client and server side clusters to work.
In the Tokyo design summit it was decided to start with the HEAD approach.

Change-Id: I60d982dd2cc79a0f13b0924507cd03d7f9c9d70b
Closes-Bug: #1277223
2016-03-23 17:42:48 +00:00
oshritf
0ad1b0cca1 Container sync nodes shuffle cleanup
Since commit "Update container sync to use internal client" get_object is
done using internal_client and not directly on nodes which makes the block
of code to shuffle the nodes redundant.

Change-Id: I45a6dab05f6f87510cf73102b1ed191238209efe
2016-03-20 13:15:44 +02:00
Samuel Merritt
9430f4c9f5 Move HeaderKeyDict to avoid an inline import
There was a function in swift.common.utils that was importing
swob.HeaderKeyDict at call time. It couldn't import it at compilation
time since utils can't import from swob or else it blows up with a
circular import error.

This commit just moves HeaderKeyDict into swift.common.header_key_dict
so that we can remove the inline import.

Change-Id: I656fde8cc2e125327c26c589cf1045cb81ffc7e5
2016-03-07 12:26:48 -08:00
Alistair Coles
e91de49d68 Update container on fast-POST
This patch makes a number of changes to enable content-type
metadata to be updated when using the fast-POST mode of
operation, as proposed in the associated spec [1].

* the object server and diskfile are modified to allow
  content-type to be updated by a POST and the updated value
  to be stored in .meta files.

* the object server accepts PUTs and DELETEs with older
  timestamps than existing .meta files. This is to be
  consistent with replication that will leave a later .meta
  file in place when replicating a .data file.

* the diskfile interface is modified to provide accessor
  methods for the content-type and its timestamp.

* the naming of .meta files is modified to encode two
  timestamps when the .meta file contains a content-type value
  that was set prior to the latest metadata update; this
  enables consistency to be achieved when rsync is used for
  replication.

* ssync is modified to sync meta files when content-type
  differs between local and remote copies of objects.

* the object server issues container updates when handling
  POST requests, notifying the container server of the current
  immutable metadata (etag, size, hash, swift_bytes),
  content-type with their respective timestamps, and the
  mutable metadata timestamp.

* the container server maintains the most recently reported
  values for immutable metadata, content-type and mutable
  metadata, each with their respective timestamps, in a single
  db row.

* new probe tests verify that replication achieves eventual
  consistency of containers and objects after discrete updates
  to content-type and mutable metadata, and that container-sync
  sync's objects after fast-post updates.

[1] spec change-id: I60688efc3df692d3a39557114dca8c5490f7837e

Change-Id: Ia597cd460bb5fd40aa92e886e3e18a7542603d01
2016-03-03 14:25:10 +00:00
Jenkins
5fc3ad7b53 Merge "Fix time-shifting of objects PUT with container-sync" 2016-03-02 20:59:26 +00:00
Tim Burke
fe70898dac Require account/container metadata be UTF-8
Otherwise, we get a UnicodeDecodeError when we call json.dumps()

Change-Id: Ie200d029e1fd7f0ff0956c8ced98207e11ef9080
2016-02-29 10:27:29 +00:00
Alistair Coles
f2fca9aafa Fix time-shifting of objects PUT with container-sync
When container-sync PUTs an object to a destination container
it uses the timestamp from the container row rather than the
actual timestamp of the object being copied. The actual timestamp
of the object can be newer, so the sync'd object may end up with
the right content but at the wrong, older, timestamp.

This patch changes the timestamp sent with the sync'd object
to be that of the actual source object being sent.

Drive-by fix to make code more readable by removing a variable
rename mid-function, fix a typo and remove a redundant function
call.

Change-Id: I800e6de4cdeea289864414980a96f5929281da04
Closes-Bug: #1540884
2016-02-04 13:28:06 +00:00
Eran Rom
2f8e604047 Fixing typo in unit test
The typo does not influence the correctness of the test
yet its ugly. bhhha.

Change-Id: I62e511bae23523892b87309dd3c50aea61742f2d
2016-02-03 08:59:53 +02:00
Timur Alperovich
432e280aef Correctly handle keys starting with the delimiter.
When processing keys where the names start with the delimiter
character, swift should list only the delimiter character. To get the
list of nested keys, the caller should also supply the prefix which is
equal to the delimiter.

Added a functional test and unit tests to verify this behavior.

Fixes Bug: 1475018

Change-Id: I27701a31bfa22842c272b7781738e8c546b82cbc
2016-01-06 12:29:20 -08:00
Eran Rom
85a0a6a28e Container-Sync to iterate only over synced containers
This change introduces a sync_store which holds only containers that
are enabled for sync. The store is implemented using a directory
structure that resembles that of the containers directory, but has
entries only for containers enabled for sync.
The store is maintained in two ways:
1. Preemptively by the container server when processing
PUT/POST/DELETE operations targeted at containers with
x-container-sync-key / x-container-sync-to
2. In the background using the containers replicator
whenever it processes a container set up for sync

The change updates [1]
[1] http://docs.openstack.org/developer/swift/overview_container_sync.html

Change-Id: I9ae4d4c7ff6336611df4122b7c753cc4fa46c0ff
Closes-Bug: #1476623
2016-01-06 16:46:31 +02:00
Kota Tsuyuzaki
b68311db95 Fix reconciler test to calc lastmodified as UTC
Swift reconciler calculates the last-modified date as UTC but
current test calculates it as local time zone. It triggers unit
test failure in non-UTC environment.

This patch fixes the test to calculate the last-modified as UTC
as well.

Change-Id: Ia0053f350daf2cb8c61ac01a933924b6e4b0cb37
Closes-Bug: #1526588
2015-12-16 17:17:06 +05:30
Richard Hawkins
9d7f71d575 Modify functional tests to use ostestr/testr
Defcore uses Tempest, which uses Test Repository.
This change makes it easier for Defcore to pull functional
tests from Swift and run them.  Additionally, using testr
allows tests to be run in parallel.

Concurrency set to 1 for now, >1 causes failures for
reasons that are still TBD.

With switch to ostestr all the server logs are being sent to stdout
which makes it completely unreadable. Suppressing the logs by default
now with a flag to enable it if desired.

Co-Authored-By: John Dickinson <me@not.mn>
Co-Authored-By: Robert Collins <rbtcollins@hpe.com>
Co-Authored-By: Matthew Oliver <matt@oliver.net.au>
Co-Authored-By: Ganesh Maharaj Mahalingam <ganesh.mahalingam@intel.com>

Change-Id: I53ef4a116996a772cf1f3abc2eb0ad60047322d5
Related-Bug: 1177924
2015-12-15 22:30:44 +00:00
Jenkins
dc774390da Merge "Reverse-listings follow-up" 2015-11-24 20:03:53 +00:00
Jenkins
f48c6f508e Merge "Add container and account reverse listings" 2015-11-24 17:54:57 +00:00
Tim Burke
41897d96a7 Reverse-listings follow-up
* With the end_prefix changes in the original commit, we no longer need
   the `or not name.startswith(prefix)` check.
 * Improve test coverage of reverse path listings.

Change-Id: Iaa7d4b83647c3c150be95f88cb3cc9e4f0e33979
2015-11-24 08:53:51 -08:00
Matthew Oliver
7c1e6cd583 Add container and account reverse listings
This change adds the ability to tell the container or account server to
reverse their listings. This is done by sending a reverse=TRUE_VALUE,

Where TRUE_VALUE is one of the values true can be in common/utils:

  TRUE_VALUES = set(('true', '1', 'yes', 'on', 't', 'y'))

For example:

  curl -i -X GET -H "X-Auth-Token: $TOKEN" $STORAGE_URL/c/?reverse=on

I borrowed the swapping of the markers code from Kevin's old change,
thanks Kevin. And Tim Burke added some real nuggets of awesomeness.

DocImpact
Co-Authored-By: Kevin McDonald <kmcdonald@softlayer.com>
Co-Authored-By: Tim Burke <tim.burke@gmail.com>
Implements: blueprint reverse-object-listing

Change-Id: I5eb655360ac95042877da26d18707aebc11c02f6
2015-11-24 15:08:45 +00:00
Jenkins
c351059577 Merge "Added unit test cases for container/auditor.py" 2015-11-23 20:17:40 +00:00
Sivasathurappan Radhakrishnan
c4eeea7820 Added unit test cases for container/auditor.py
Added unit test cases to cover all code path in _one_audit_pass
function in container/auditor.py

Change-Id: I8b89e94f1492e4366af3ac4260587e988ba29408
2015-11-20 16:07:17 +00:00
Zack M. Davis
1b8b08039a remove remaining simplejson uses, prefer standard library import
a1c32702, 736cf54a, and 38787d0f remove uses of `simplejson` from
various parts of Swift in favor of the standard libary `json`
module (introduced in Python 2.6). This commit performs the remaining
`simplejson` to `json` replacements, removes two comments highlighting
quirks of simplejson with respect to Unicode, and removes the references
to it in setup documentation and requirements.txt.

There were a lot of places where we were importing json from
swift.common.utils, which is less intuitive than a direct `import json`,
so that replacement is made as well.

(And in two more tiny drive-bys, we add some pretty-indenting to an XML
fragment and use `super` rather than naming a base class explicitly.)

Change-Id: I769e88dda7f76ce15cf7ce930dc1874d24f9498a
2015-11-16 12:34:24 -08:00
Jenkins
aecf596b20 Merge "Added unit test cases for server.py" 2015-11-11 21:01:46 +00:00
Sivasathurappan Radhakrishnan
ce173e9ed2 Added unit test cases for server.py
Added unit test cases to cover all code paths in REPLICATE and __call__
functions in account/server.py and container/server.py

Change-Id: Ia335e9a6668821d3e34b12fc3a133a707880e87f
2015-11-10 21:38:47 +00:00
Jenkins
ec9095bf58 Merge "Get rid of contextlib.nested() for py3" 2015-11-05 12:20:06 +00:00
Samuel Merritt
e31ecb24b6 Get rid of contextlib.nested() for py3
contextlib.nested() is missing completely in Python 3.

Since 2.7, we can use multiple context managers in a 'with' statement,
like so:

    with thing1() as t1, thing2() as t2:
        do_stuff()

Now, if we had some code that needed to nest an arbitrary number of
context managers, there's stuff we could do with contextlib.ExitStack
and such... but we don't. We only use contextlib.nested() in tests to
set up bunches of mocks without crazy-deep indentation, and all that
stuff fits perfectly into multiple-context-manager 'with' statements.

Change-Id: Id472958b007948f05dbd4c7fb8cf3ffab58e2681
2015-10-23 11:44:54 -07:00
Alistair Coles
5d8d2e98ee Minor improvement to updater unit tests
Follow up for change I7c57bba053711a27d3802efe6f2a0bf53483a54f

The current tests won't prevent this kind of regression in the
updaters' __init__ methods:

  self.node_timeout = int(float(conf.get('node_timeout', 10)))

so this makes them a little tighter.

Change-Id: I60bd79ac392deb1e8a108357d48474dddd9028c1
2015-10-23 16:38:24 +01:00
Lisak, Peter
b6b7578190 node_timeout as float in configs
It is more convenient to use float node_timeout for fine tunning latency.

Change-Id: I7c57bba053711a27d3802efe6f2a0bf53483a54f
2015-10-19 21:14:34 +02:00
Matthew Oliver
4a13dcc4a8 Make db_replicator usync smaller containers
The current rule inside the db_replicator is to rsync+merge
containers during replication if the difference between rowids
differ by more than 50%:

  # if the difference in rowids between the two differs by
  # more than 50%, rsync then do a remote merge.
  if rinfo['max_row'] / float(info['max_row']) < 0.5:

This mean on smaller containers, that only have few rows, and differ
by a small number still rsync+merge rather then copying rows.

This change adds a new condition, the difference in the rowids must
be greater than the defined per_diff otherwise usync will be used:

  # if the difference in rowids between the two differs by
  # more than 50% and the difference is greater than per_diff,
  # rsync then do a remote merge.
  # NOTE: difference > per_diff stops us from dropping to rsync
  # on smaller containers, who have only a few rows to sync.
  if rinfo['max_row'] / float(info['max_row']) < 0.5 and \
          info['max_row'] - rinfo['max_row'] > self.per_diff:

Change-Id: I9e779f71bf37714919a525404565dd075762b0d4
Closes-bug: #1019712
2015-10-19 15:26:12 +01:00
janonymous
1882801be1 pep8 fix: assertNotEquals -> assertNotEqual
assertNotEquals is deprecated in py3

Change-Id: Ib611351987bed1199fb8f73a750955a61d022d0a
2015-10-12 07:40:07 +00:00
janonymous
f5f9d791b0 pep8 fix: assertEquals -> assertEqual
assertEquals is deprecated in py3, replacing it.

Change-Id: Ida206abbb13c320095bb9e3b25a2b66cc31bfba8
Co-Authored-By: Ondřej Nový <ondrej.novy@firma.seznam.cz>
2015-10-11 12:57:25 +02:00
Victor Stinner
c0af385173 py3: Replace urllib imports with six.moves.urllib
The urllib, urllib2 and urlparse modules of Python 2 were reorganized
into a new urllib namespace on Python 3. Replace urllib, urllib2 and
urlparse imports with six.moves.urllib to make the modified code
compatible with Python 2 and Python 3.

The initial patch was generated by the urllib operation of the sixer
tool on: bin/* swift/ test/.

Change-Id: I61a8c7fb7972eabc7da8dad3b3d34bceee5c5d93
2015-10-08 15:24:13 +02:00
Victor Stinner
f2cac20d17 py3: Replace unicode with six.text_type
The unicode type was renamed to str in Python 3. Use six.text_type to
make the modified code compatible with Python 2 and Python 3.

The initial patch was generated by the unicode operation of the sixer
tool on: bin/* swift/ test/.

Change-Id: I9e13748ccde36ee8110756202d55d3ae945d4860
2015-10-08 13:16:43 +02:00
Jenkins
84687ee324 Merge "Change POST container semantics" 2015-10-06 19:10:15 +00:00
Jenkins
bbbef0e5a6 Merge "Test if container_sweep is executed on unmounted devices" 2015-09-03 02:24:10 +00:00
Jenkins
4d4b8fcacd Merge "Add unit test for container_update for unmounted device" 2015-09-03 02:22:11 +00:00
Christian Schwede
58fcc07523 Test if container_sweep is executed on unmounted devices
This change ensures that container_sweep is not run if a device is not mounted
and mount_check is set to True.

Change-Id: I823083c8431d9e61fd426508033ec9188503957b
2015-09-02 10:53:09 +00:00
Victor Stinner
8aaacbf88d pep8: Fix hacking H232 warnings (octal)
Fix warnings "H232: Python 3.x incompatible octal 000001234 should be
written as 0o1234".

Change-Id: I9a7bbb034357783885ac3e18fe1e9e32a5951616
2015-08-19 12:05:01 -07:00
Bill Huber
5b01c5eadc Add unit test for container_update for unmounted device
This unit test case gains coverage for container/update.py
where a device (i.e. sda1) is not mounted and the code
responds with a warning logger that the device is not
mounted and continues.  Coverage increases 2% as a result.

Change-Id: I33d247a930b28604093df4ade1ce7dbbd24aac54
2015-08-18 17:43:26 -05:00
Kota Tsuyuzaki
4de6e32bca Change POST container semantics
To achieve last modified header on GETorHEAD container
we should allow POST container to overwrite put-timestamp.
That is because following patches will change the the put-timestamp
value semantics in both container db and account db as "container
last modified".

If we achieved this and followings, we will be able to retrieve the
container timestamp which is suggested when the container metadata
modified.

Example:
- Create a container.
- Change the ACL with POST container. (e.g. x-container-read)
- After that, we can know the container was changed by comparing
  between the timestamp from container creation and the last modified
  generated from put-timestamp.

Change-Id: I1a545fcd1896798dfa7cb5e5af97c78f5d7d7e4d
2015-08-12 08:26:28 -07:00
janonymous
ed3aec2146 pep8 fix: assertEquals -> assertEqual
assertEquals is deprecated in py3 in
dir: test/unit/container/*

Change-Id: I3333022ed63ce03198bc73147246d91d2442a440
2015-08-06 00:18:52 +05:30
Victor Stinner
389a97e352 Fix pep8 E warning for hacking 0.10
Fix pep8 warnings of the E category of hacking 0.10:

* E113: unexpected indentation
* E121: continuation line under-indented for hanging indent
* E122: continuation line missing indentation or outdented
* E123: closing bracket does not match indentation of opening bracket's
  line
* E126: continuation line over-indented for hanging indent
* E251: unexpected spaces around keyword / parameter equals

Change-Id: I0b24eebdf1a37dc1b572b6c9a3d3d4832d050237
2015-07-30 09:33:41 +02:00
Victor Stinner
d719064e78 Fix warning pep8 E128 warning of hacking 0.10
Fix the warning E128: "continuation line under-indented for visual
indent" of pep8.

Change-Id: Ie6c6ae341fe3d6281f2095c1d756d552fa5937f9
2015-07-30 09:33:41 +02:00
Victor Stinner
a0db56dcde Fix pep8 E265 warning of hacking 0.10
Fix the warning E265 "block comment should start with '# '" added in pep
1.5.

Change-Id: Ib57282e958be9c7cddffc7bca34fbbf1d4c460fd
2015-07-30 09:33:18 +02:00
Jenkins
e7205fd7d6 Merge "cPickle is deprecated in py3, replacing it from six.moves" 2015-07-28 12:33:24 +00:00
Jenkins
187cea5445 Merge "Replace StringIO with BytesIO for WSGI input" 2015-07-24 06:52:40 +00:00