464 Commits

Author SHA1 Message Date
Jenkins
dd405d9dd4 Merge "Fix ClientException handling in Container Sync" 2016-01-13 14:44:00 +00:00
Hisashi Osanai
23c7a58f8f Fix ClientException handling in Container Sync
swift/container/sync.py uses swift.common.internal_client.delete_object
and put_object and expected these methods raise ClientException.
But delete_object and put_object never raise the exception so this patch
raises ClientException when urllib2 library raises HTTPError.

Co-Authored-By: Eran Rom <eranr@il.ibm.com>
Closes-Bug: #1419901
Change-Id: I58cbf77988979a07998a46d9d81be84d29b0d9bf
2016-01-07 10:17:20 +00:00
Ondřej Nový
3b1591f235 swift-init: New option kill-after-timeout
This option send SIGKILL to daemon after kill_wait period.
When daemon hangs and doesn't respond to SIGTERM/SIGHUP
there is no way to stop it using swift-init now. Classic
init scripts in Linux kills hanged process after grace
period and this patch add same behaviour. This is most
usefull when using "restart" on hanged daemon.

Change-Id: I8c932b673a0f51e52132df87ea2f4396f4bba9d8
2016-01-05 11:34:03 +01:00
Jenkins
b37205fe2d Merge "Improve swift-init usage statement" 2015-11-26 01:43:28 +00:00
Alistair Coles
e06c874394 Improve swift-init usage statement
Clarify the behavior of strict and non-strict options.

Define what <server> and <config> specify on the command line.

Drive-by fix for missing param in search_tree docstring.

Change-Id: I89fff88a088bc73001464b1fa8240e14a61a117d
2015-11-25 18:41:11 +00:00
Jenkins
caebea16d6 Merge "swift-init return codes" 2015-11-25 16:25:55 +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
Lisak, Peter
7b7c6c5249 swift-init return codes
Currently, swift-init returns zero if can't locate config on start.
Because of this problem, it is not possible to distinguish if managed
to start server.

Due to legacy two new complementary options are added. Default is context
dependent.
--strict returns non-zero if some config is missing (default mode
if explicitly named server)
--non-strict returns zero even if some config is missing (default mode
if alias is used)

As a side effect:
If some of demanded servers already running it does not try to start
unstarted and also returns non-zero (in strict mode). That is still sufficient
for the goal of patch.

For future improvements LSB status codes should be considered.

DocImpact
Change-Id: I7750abd4a94875b46f83f4aeee8509388d543c2b
2015-11-16 07:07:11 +01: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
Jenkins
6a9b868ae6 Merge "Python3: Fix Remaining issues of python3 compatibility in bin directory" 2015-10-08 08:41:34 +00:00
Samuel Merritt
e02609c66a Preserve traceback in swift-dispersion-report
Commit c690bcb fixed a bug in the dispersion report, but changed this
from a bare "raise" to "raise err", which loses the traceback. Not a
big deal, but worth putting back IMO.

Change-Id: Id5b72153a4b8df8e3faaf1fa3fb2040e28ba85cc
2015-09-01 15:19:50 -07:00
Kazuhiro MIYAHARA
c690bcb683 Fix dispersion-reports error message
This patch fixes Swift to show message
"No objects to query. Has swift-dispersion-populate been run?"
for "swift-dispersion-report —object-only”
with no container for object dispersion.

Change-Id: I82da56709cfc296a27f5180681709bc56adbc13d
Closes-Bug: #1468120
2015-08-26 11:32:06 +09:00
kenichiro matsuda
81816bebe6 Fix shebang of commands
Fix shebang of following commands.
  $ grep '#!/usr/bin/python' swift/bin/*
  swift/bin/swift-account-info:#!/usr/bin/python
  swift/bin/swift-container-info:#!/usr/bin/python
  swift/bin/swift-container-sync:#!/usr/bin/python
  swift/bin/swift-recon:#!/usr/bin/python
  swift/bin/swift-ring-builder:#!/usr/bin/python
  swift/bin/swift-ring-builder-analyzer:#!/usr/bin/python

Change-Id: I564d1d8abd76eba57730fc2f30263b0a0f809867
Closes-Bug: #1481623
2015-08-06 11:02:40 +09:00
Jenkins
e1683fdb2e Merge "Support keystone v3 domains in swift-dispersion" 2015-07-31 06:59:01 +00: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
Falk Reimann
363a256e58 Support keystone v3 domains in swift-dispersion
This provides the capability to specify a project_name,
project_domain_name and user_domain_name in /etc/swift/dispersion.conf.
If this values are set in dispersion.conf they get populated to the
swift-client.  With this it is possible to have a specific dispersion
project specified, which is not the keystone default domain.  Changes
were applied to swift-dispersion-populate and swift-dispersion-report.
Relevant man pages, the example dispersion.conf and the admin guide were
updated accordingly.

DocImpact
Closes-Bug: #1468374

Change-Id: I0e716f8d281b4d0f510bc568bcee4a13fc480ff7
2015-07-24 13:40:24 -05:00
janonymous
78cb608ff7 Python3: Fix Remaining issues of python3 compatibility in bin directory
Changes Of py3 in bin :

* https://review.openstack.org/#/c/196835/
* ConfigParser from six.moves

Change-Id: Ic0374c8e09dfd595ec12c4d31b17dad30eaa803c
2015-07-24 19:30:04 +05:30
Victor Stinner
6e70f3fa32 Get StringIO and cStringIO from six.moves
* replace "from cStringIO import StringIO"
  with "from six.moves import cStringIO as StringIO"
* replace "from StringIO import StringIO"
  with "from six import StringIO"
* replace "import cStringIO" and "cStringIO.StringIO()"
  with "from six import moves" and "moves.cStringIO()"
* replace "import StringIO" and "StringIO.StringIO()"
  with "import six" and "six.StringIO()"

This patch was generated by the stringio operation of the sixer tool:
https://pypi.python.org/pypi/sixer

Change-Id: Iacba77fec3045f96773d1090c0bd48613729a561
2015-07-15 16:56:33 +02:00
Jenkins
395b703305 Merge "Replace dict.iteritems() with dict.items() in bin directory of swift." 2015-07-15 07:39:28 +00:00
Jenkins
668d543c86 Merge "Add ring-builder analyzer." 2015-07-10 20:12:34 +00:00
janonymous
cd20961abd Replace dict.iteritems() with dict.items() in bin directory of swift.
The iteritems() of Python 2 dictionaries has been renamed to items() on
Python 3.

Change-Id: I4bdc064c90bab56cd60f2dca2a5a78426ffbb31c
2015-07-05 11:08:35 +05:30
janonymous
8eca02d3a1 Replace xrange() with six.moves.range()
xrange is no longer available in py3.
replacing xrange with range from six.moves

Change-Id: Ib863c316a0724bd9c4f53c2e5a8d1bcd42c4dc5a
2015-07-03 01:00:28 +05:30
Samuel Merritt
ccf0758ef1 Add ring-builder analyzer.
This is a tool to help developers quantify changes to the ring
builder. It takes a scenario (JSON file) describing the builder's
basic parameters (part_power, replicas, etc.) and a number of
"rounds", where each round is a set of operations to perform on the
builder. For each round, the operations are applied, and then the
builder is rebalanced until it reaches a steady state.

The idea is that a developer observes the ring builder behaving
suboptimally, writes a scenario to reproduce the behavior, modifies
the ring builder to fix it, and references the scenario with the
commit so that others can see that things have improved.

I decided to write this after writing my fourth or fifth hacky one-off
script to reproduce some bad behavior in the ring builder.

Change-Id: I114242748368f142304aab90a6d99c1337bced4c
2015-07-02 08:16:03 -07:00
Jenkins
f5d6f8c23a Merge "Add policy support to dispersion tools" 2015-06-25 09:42:00 +00:00
paul luse
e6165a7879 Add policy support to dispersion tools
Doesn't work for anything other than policy 0. updated to allow user
to specify policy name on cmd line (as with object-info) which
then makes populate/report work with 3x, 2x, or EC style policies

Change-Id: Ib7c298f0f6d666b1ecca25315b88539f45cf9f95
Closes-Bug: 1458688
2015-06-23 02:14:02 -07:00
Mark Seger
af734b3fb6 Change usage help and Attention messages to warnings
Change-Id: I1396aaffe36e739606f15f7fef37b11bd83f1fc1
2015-06-03 15:32:25 -04:00
paul luse
647b66a2ce Erasure Code Reconstructor
This patch adds the erasure code reconstructor. It follows the
design of the replicator but:
  - There is no notion of update() or update_deleted().
  - There is a single job processor
  - Jobs are processed partition by partition.
  - At the end of processing a rebalanced or handoff partition, the
    reconstructor will remove successfully reverted objects if any.

And various ssync changes such as the addition of reconstruct_fa()
function called from ssync_sender which performs the actual
reconstruction while sending the object to the receiver

Co-Authored-By: Alistair Coles <alistair.coles@hp.com>
Co-Authored-By: Thiago da Silva <thiago@redhat.com>
Co-Authored-By: John Dickinson <me@not.mn>
Co-Authored-By: Clay Gerrard <clay.gerrard@gmail.com>
Co-Authored-By: Tushar Gohad <tushar.gohad@intel.com>
Co-Authored-By: Samuel Merritt <sam@swiftstack.com>
Co-Authored-By: Christian Schwede <christian.schwede@enovance.com>
Co-Authored-By: Yuan Zhou <yuan.zhou@intel.com>
blueprint ec-reconstructor
Change-Id: I7d15620dc66ee646b223bb9fff700796cd6bef51
2015-04-14 00:52:17 -07:00
Lorcan
0a46793662 Add swift-recon feature to track swift-drive-audit error count
This is a follow-on from a previous commit which added recon info
for swift-drive-audit (https://review.openstack.org/#/c/122468/).

Here, the "--drievaudit" option is added to swift-recon tool. This
feature gives the statistics for the system-wide drive errors flagged
by swift-drive-audit. An example of the output is as follows:
(verbose mode)

swift-recon --driveaudit -v
===============================================================================
--> Starting reconnaissance on 5 hosts
===============================================================================
[2015-03-11 17:13:39] Checking drive-audit errors
-> http://1.2.3.4:6000/recon/driveaudit: {'drive_audit_errors': 14}
-> http://1.2.3.5:6000/recon/driveaudit: {'drive_audit_errors': 0}
-> http://1.2.3.6:6000/recon/driveaudit: {'drive_audit_errors': 37}
-> http://1.2.3.7:6000/recon/driveaudit: {'drive_audit_errors': 101}
-> http://1.2.3.8:6000/recon/driveaudit: {'drive_audit_errors': 0}
[drive_audit_errors] low: 0, high: 101, avg: 30.4, total: 152, Failed: 0.0%, no_result: 0, reported: 5
===============================================================================

Change-Id: Ia16c52a9d613eeb3de1a5a428d88dd1233631912
2015-03-23 11:38:32 +00:00
Jenkins
49586c6ed7 Merge "Prevent redundant commenting by drive-audit" 2015-02-03 22:33:18 +00:00
Takashi Kajinami
a270dca239 Prevent redundant commenting by drive-audit
The drive-audit detects error log about a device and comments out it
in /etc/fstab. When the error log is generated several times, it
comments out the line for each time.
This patch makes drive-audit to check if the device is already
commented out, and prevents redundant commenting out.

Change-Id: Ia542d35b58552dde0f324bb9c42531f98c9058fa
2015-02-02 22:01:29 +09:00
Samuel Merritt
3ac43e8299 Allow per-policy overrides in object replicator.
The replicator already supports --devices and --partitions to restrict
its operation to a subset of devices and partitions. However,
operators don't always want to replicate a partition in all policies
since different policies (usually) have different rings.

For example, if I know that policy 0's partition 1234 is has no
replicas on primary nodes due to over-aggressive rebalancing, I really
want to find a node where the partition isa and make the replicator
push it onto the primaries. However, if I haven't been messing with
policy 1's ring, its partition 1234 is fine. With the existing
replicator args, I get both or neither; this commit lets me get just
the useful one.

Change-Id: Ib1d58fdd228a6ee7865321e65d7c04a891fa5c49
2015-01-22 16:10:22 -08:00
Keshava Bharadwaj
1ffe6b3953 Adds console logging to swift-drive-audit
This patch adds console logging ability to swift-drive-audit.
There are cases where logging to console is necessary when drive-audit
is done. This can be consumed for flagging errors in monitoring tools
such as icinga.

DocImpact
Change-Id: Ia1e1effcbd89bd2cf6d5b8c64019f1647c736a3a
2014-12-18 14:19:12 +05:30
Cedric Dos Santos
a8751ae557 Correct misspelled words
In some files I found misspelling words.

bin/swift-reconciler-enqueue#l26
   primarly => primarily
swift/account/backend.py#l309
   ommited => omitted
swift/container/replicator.py#l158
   successfull => successful
test/unit/account/test_backend.py#1450
   non_existant_policy_index => non_existent_policy_index
test/unit/account/test_backend.py#1451
   'test-non-existant-policy'=> 'test-non-existent-policy'
test/unit/account/test_backend.py#1453
   non_existant_policy_index => non_existent_policy_index

Change-Id: I976236e3200a6fbdc20be464acff182b6cface81
2014-11-25 15:44:30 +00:00
Daisuke Morita
2792fe81a9 Show the sum of every policy's amount in /recon/async
After the release of Swift ver. 2.0.0, some recon responses do not
show each policy's information yet. To make things worse, some recon
results only count on policy-0's score, therefore the total is not
shown in the recon results.

With this patch, async_pending count of recon results becomes
policy-aware. Suppose a number of async_pending files for policy-0 is 2
and a number for policy-1 is 3, recon sums up every policy's amount
as follows.

$ curl http://<host>:<port>/recon/async
{"async_pending": 5} # It showed 2 before this commit

Related-Bug: 1375332
Change-Id: Ifc88b8c9e06b9f022a926a87ed807e938e1e0412
2014-11-14 20:47:04 +09:00
Filippo Giunchedi
dec9448c87 swift-drive-audit: pass logger to get_errors
Closes-Bug: #1379767
Change-Id: Ie8ec5e9ffb977ab39aedeb878e6aae9f0b62530b
2014-10-10 12:51:53 +01:00
Jenkins
8647f86494 Merge "Add new features to swift-drive-audit" 2014-10-10 09:24:41 +00:00
Lorcan
cb20763893 Add new features to swift-drive-audit
This patch adds two new features to swift-drive-audit. The first
is an option in the drive-audit.conf file that allows the operator
to prevent the drives ever being unmounted automatically,
regardless of the amount of errors present. This could be of
benefit in very small systems consisting of only one or two drives
where the operator would like to manually unmount/fix the
particular drive(s) and minimise any potential downtime.

The second is another option in drive-audit.conf that allows the
operator to select a recon directory. This directory will then
have a drive.recon file which will keep an up-to-date record of
the swift drives and any errors associated with them. An example
of the output would be as follows:

{"/srv/node/disk2": "0", "/srv/node/disk3": "25", "/srv/node/disk0": "0",
"/srv/node/disk1": "0", "/srv/node/disk10": "0", "/srv/node/disk7": "0",
"/srv/node/disk4": "137", "/srv/node/disk5": "0", "/srv/node/disk8": "0",
"/srv/node/disk9": "0", "/srv/node/disk6": "0", "/srv/node/disk11": "60"}

This would allow the operator to monitor the errors on the swift
drives without having to spend time searching through logs. Also, if
this is accepted, it should be possible to add an option to
swift-recon that would keep track of this at a system level.

Change-Id: Ib5dacf8622b7363e070c274c7c30c8ead448a055
2014-09-25 16:27:25 +01:00
Jenkins
607e2ed2e3 Merge "Add "--no-overlap" option to swift-dispersion populate" 2014-09-22 15:44:14 +00:00
Lorcan
4faf170270 Add "--no-overlap" option to swift-dispersion populate
This change allows the user to use a "--no-overlap" parameter when
running the tool multiple times. It will increase the coverage by
whatever is specified in the dispersion_coverage field of the conf
file in a manner where existing container/objects are left in place
and no partition is populated more than once.

Related-Bug: #1233045

Change-Id: I139fed2f4c967ba18d073b7ecd1e946ed4da1271
2014-09-19 10:44:30 +01:00
John Dickinson
b7281cf2c5 make the bind_port config setting required
In a long-term effort to change the recommended ports for Swift,
the first step is to require the bind_port in config files. Later,
we can change the recommended setting.

Anyone currently explicitly setting the ports will not be affected.
Anyone not setting the ports will need to specify them to match their
rings.

DocImpact

Change-Id: Icca83a263acdd0afc9016424a3e9f8c15e944789
2014-09-08 07:28:43 -07:00
Samuel Merritt
4f2bb9f271 Make swift-form-signature testable
Moved the body of bin/swift-form-signature into
swift/cli/form_signature.py, like was done with swift-ring-builder and
others. Added a couple basic tests; there's not 100% coverage, but
it's better than the 0% coverage we had before.

It's almost a straight forklift, but I changed exit() calls to return
statements.

Change-Id: Ie2f702c070da24d9cdface83b9e838e9e2965085
2014-07-24 14:38:53 -07:00
Yuan Zhou
6cc10d17de Update bin scripts to be storage policy aware
swift-container-info:
    Print policy container info

swift-object-info:
    Allow to specify storage policy name when looking for object info
    Notify if there is missmatch between ring location and the actual
    object path in filesystem

swift-get-nodes:
    Allow to specify storage policy name when looking for account/
    container/object ring location
    Notify if there is missmatch between ring and the policy

Lookup policy name in swift.conf; 'Legacy' container will use
policy-0's name; 'Unknown' is shown if policy not found in swift.conf

DocImpact
Implements: blueprint storage-policies
Change-Id: I450d40dc6e2d8f759187dff36d658e52737ae2a5
2014-06-18 20:57:09 -07:00
Clay Gerrard
3fc4d6f91d Add container-reconciler daemon
This daemon will take objects that are in the wrong storage policy and
move them to the right ones, or delete requests that went to the wrong
storage policy and apply them to the right ones. It operates on a
queue similar to the object-expirer's queue.

Discovering that the object is in the wrong policy will be done in
subsequent commits by the container replicator; this is the daemon
that handles them once they happen.

Like the object expirer, you only need to run one of these per cluster
see etc/container-reconciler.conf.

DocImpact
Implements: blueprint storage-policies
Change-Id: I5ea62eb77ddcbc7cfebf903429f2ee4c098771c9
2014-06-18 17:31:39 -07:00
Jenkins
c384d76c57 Merge "Add --quoted option to swift-temp-url" 2014-06-03 05:10:28 +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
Clay Gerrard
b7659bee26 Add --quoted option to swift-temp-url
If you have a path with special characters it may be easier to hand them to
swift-temp-url prequoted than try to escape them on the command line.  By the
time common.middleware.tempurl gets ahold of the path it's unquoted so we do
the same before calculating the hmac but still use the pre-quoted path output
to the commandline.

Change-Id: Ia1a9666e487b1e70e4db7cd597bc6a1027e3e918
2014-05-02 20:11:12 -07:00
Luis de Bethencourt
3af5216543 Sort the log file dates in reverse order
We want to show log files in descending order.

Change-Id: I6f79d9f5a73afa43efec36c3ca99afcde3fe7813
Closes-Bug: #1311405
2014-04-25 11:19:47 -04:00
Yuan Zhou
39f5eab890 Clean up swift-{account, container}-info
Reuse common code; add unit tests; ensured coverage was at 100%.

Change-Id: Id6fcc7cb07fd178e00d43968e3e2cc03226fdc05
2014-04-03 09:54:58 -04:00
Jenkins
6e44a8499a Merge "Update swift-get-nodes to use storage_directory util func" 2014-03-31 19:36:01 +00:00
Jenkins
a7d54467cd Merge "Added swift-account-info tool." 2014-03-31 18:00:17 +00:00