513 Commits

Author SHA1 Message Date
Thiago da Silva
a7c5ca0806 Fix locking in swift-recon-cron
The previous locking method would leave the lock dir lying around
if the process died unexpectedly, preventing others swift-recon-cron
process from running sucessfuly and requiring a manual clean.

Change-Id: Icb328b2766057a2a4d126f63e2d6dfa5163dd223
2018-08-15 21:51:14 +00:00
Zuul
a3cc7ccc69 Merge "Experimental swift-ring-composer CLI to build composite rings" 2018-06-15 04:27:43 +00:00
Alistair Coles
6b626f2f98 Experimental swift-ring-composer CLI to build composite rings
Provides a simple, experimental, CLI tool to generate a
composite ring from a list of component builder files.

For example:

  swift-ring-composer <composite-file> compose \
      <builder-file> <builder-file> --output <ring-file>

Commands available:

- compose: compose a list of builder file to a composite ring
- show: show the metadata for a composite ring

Co-Authored-By: Kota Tsuyuzaki <tsuyuzaki.kota@lab.ntt.co.jp>
Co-Authored-By: Matthew Oliver <matt@oliver.net.au>
Change-Id: I25a79e71c13af352e19e4358f60545265b51584f
2018-06-14 09:50:55 +01:00
Matthew Oliver
2641814010 Add sharder daemon, manage_shard_ranges tool and probe tests
The sharder daemon visits container dbs and when necessary executes
the sharding workflow on the db.

The workflow is, in overview:

- perform an audit of the container for sharding purposes.

- move any misplaced objects that do not belong in the container
  to their correct shard.

- move shard ranges from FOUND state to CREATED state by creating
  shard containers.

- move shard ranges from CREATED to CLEAVED state by cleaving objects
  to shard dbs and replicating those dbs. By default this is done in
  batches of 2 shard ranges per visit.

Additionally, when the auto_shard option is True (NOT yet recommeneded
in production), the sharder will identify shard ranges for containers
that have exceeded the threshold for sharding, and will also manage
the sharding and shrinking of shard containers.

The manage_shard_ranges tool provides a means to manually identify
shard ranges and merge them to a container in order to trigger
sharding. This is currently the recommended way to shard a container.

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

Change-Id: I7f192209d4d5580f5a0aa6838f9f04e436cf6b1f
2018-05-18 18:48:13 +01:00
Zuul
0bc52a6036 Merge "swift-recon-cron: do not get confused by files in /srv/node" 2018-04-13 04:14:31 +00:00
Zuul
c9ddee7aac Merge "swift-(account|container)-info: tolerate LockTimeouts" 2018-04-11 07:24:53 +00:00
Zuul
e4660a3e31 Merge "Add manpage for swift-object-relinker" 2018-04-11 01:35:07 +00:00
Tim Burke
5b68eb5396 swift-(account|container)-info: tolerate LockTimeouts
I'm not really clear on why a sqlite3.OperationalError should cause us to
retry with stale_reads_ok=True, but swift.common.exceptions.LockTimeout
*definitely* should.

Change-Id: I707dec1d11b8db80bc8fbee30662b319bf10d6a5
2018-04-10 17:09:07 -07:00
Zuul
b20893f540 Merge "Support -d <devs> and -p <partitions> in DB replicators." 2018-03-20 00:04:01 +00:00
Zuul
2c7e12289f Merge "Optionally drop common prefixes in swift-*-info output" 2018-03-13 03:39:02 +00:00
Samuel Merritt
b08c70d38e Support -d <devs> and -p <partitions> in DB replicators.
Similar to the object replicator and reconstructor, these arguments
are comma-separated lists of device names and partitions,
respectively, on which the account or container replicator will
operate. Other devices and partitions are ignored.

Change-Id: Ic108f5c38f700ac4c7bcf8315bf4c55306951361
2018-03-05 16:26:19 -08:00
Tim Burke
36c42974d6 py3: Port more CLI tools
Bring under test

 - test/unit/cli/test_dispersion_report.py
 - test/unit/cli/test_info.py and
 - test/unit/cli/test_relinker.py

I've verified that swift-*-info (at least) behave reasonably under
py3, even swift-object-info when there's non-utf8 metadata on the
data/meta file.

Change-Id: Ifed4b8059337c395e56f5e9f8d939c34fe4ff8dd
2018-02-28 21:10:01 +00:00
Clay Gerrard
55a1b63db5 Let recon-cron work with conf.d
Change-Id: I862b74e0d9b20ba149581c1add6473dc1e5b2859
2018-01-11 12:36:45 -08:00
Ondřej Nový
611b28f73a Add manpage for swift-object-relinker
Change-Id: I56dd9c646faba91e9f124f343ea0e08f8c3c4249
2017-12-09 19:10:35 +01:00
Tim Burke
250da37a7b Remove swift-temp-url script
This has been deprecated since Swift 2.10.0 (Newton) including a
message that it would go away. Let's actually remove it.

Change-Id: I7d3659761c71119363ff2c0c750e37b4c6374a39
Related-Change: Ifa8bf636f20f82db4845b02d1b58699edaa39356
2017-10-13 23:28:09 +00:00
Tim Burke
79905ae794 Replace SOSO auth prefix in examples with more-standard AUTH
Change-Id: I98643d6acf248840a8360f31e446bc8ecb834898
2017-09-27 23:49:59 +00:00
Tim Burke
4716d3da11 swift-account-audit: compare each etag to the hash from container
...rather than only comparing the ETag from the last response over and
over again.

NB: This tool *does not* like EC data :-(

Change-Id: Idd37f94b07f607ab8a404dd986760361c39af029
Closes-Bug: 1266636
2017-09-27 23:49:59 +00:00
Tim Burke
f95befb37f Optionally drop common prefixes in swift-*-info output
Add a --drop-prefixes flag to swift-account-info, swift-container-info,
and swift-object-info. This makes the output between the three more
consistent.

Change-Id: I98252ff74c4983eaad0a93d9a9fc527c74ffce68
2017-09-13 22:47:04 +00:00
Christian Schwede
cbddec340e Add bin/swift-dispersion-report
Change-Id: I81736080fc478c2b69d5b71edd0cada39aad9400
2017-09-13 05:57:30 +00:00
Christian Schwede
b77de5393f Make swift-dispersion-report importable
This patch allows to import the dispersion report tool, and thus making
it more easily usable within other Python tools. This can be also used
in a follow up patch to add some tests for the report tool.

It also fixes a bug when using the "--dump-json" option - until now it
returned the policy name and made the JSON invalid.

Change-Id: Ie0d52a1a54fc152bb72cbb3f84dcc36a8dad972a
2017-09-13 05:56:34 +00:00
Alistair Coles
b599b48f69 Clarify usage of replicator and reconstructor override options
Clarify in usage statement and man pages that CLI override options for
swift-object-reconstructor and swift-object-replicator only have
effect when --once is used.

Also add a link to object reconstructor source code docs to the doc
index page for consistency with the other object services.

Change-Id: If348b340d59a672d3a19d4df231ebdb74f4aed51
2017-07-26 12:53:46 +01:00
Christian Schwede
2410b616bb Fix swiftdir option and usage of storage policy aliases
If swift-recon/swift-get-nodes/swift-object-info is used with the
swiftdir option they will read rings from the given directory; however
they are still using /etc/swift/swift.conf to find the policies on the
current node.

This makes it impossible to maintain a local swift.conf copy (if you
don't have write access to /etc/swift) or check multiple clusters from
the same node.

Until now swift-recon was also not usable with storage policy aliases,
this patch fixes this as well.

Closes-Bug: 1577582
Closes-Bug: 1604707
Closes-Bug: 1617951
Co-Authored-By: Alistair Coles <alistairncoles@gmail.com>
Co-Authored-By: Thiago da Silva <thiago@redhat.com>
Change-Id: I13188d42ec19e32e4420739eacd1e5b454af2ae3
2017-07-12 16:23:04 -04:00
Jenkins
e94b383655 Merge "Add support to increase object ring partition power" 2017-07-05 14:40:42 +00:00
Alistair Coles
3cccd5a0ed Make bin/swift-get-nodes executable
Change-Id: I510e05f4cf16cc6740f673c27cea6bc3899938c1
2017-06-20 11:47:00 +01:00
Christian Schwede
e1140666d6 Add support to increase object ring partition power
This patch adds methods to increase the partition power of an existing
object ring without downtime for the users using a 3-step process. Data
won't be moved to other nodes; objects using the new increased partition
power will be located on the same device and are hardlinked to avoid
data movement.

1. A new setting "next_part_power" will be added to the rings, and once
the proxy server reloaded the rings it will send this value to the
object servers on any write operation. Object servers will now create a
hard-link in the new location to the original DiskFile object. Already
existing data will be relinked using a new tool in the new locations
using hardlinks.

2. The actual partition power itself will be increased. Servers will now
use the new partition power to read from and write to. No longer
required hard links in the old object location have to be removed now by
the relinker tool; the relinker tool reads the next_part_power setting
to find object locations that need to be cleaned up.

3. The "next_part_power" flag will be removed.

This mostly implements the spec in [1]; however it's not using an
"epoch" as described there. The idea of the epoch was to store data
using different partition powers in their own namespace to avoid
conflicts with auditors and replicators as well as being able to abort
such an operation and just remove the new tree.  This would require some
heavy change of the on-disk data layout, and other object-server
implementations would be required to adopt this scheme too.

Instead the object-replicator is now aware that there is a partition
power increase in progress and will skip replication of data in that
storage policy; the relinker tool should be simply run and afterwards
the partition power will be increased. This shouldn't take that much
time (it's only walking the filesystem and hardlinking); impact should
be low therefore. The relinker should be run on all storage nodes at the
same time in parallel to decrease the required time (though this is not
mandatory). Failures during relinking should not affect cluster
operations - relinking can be even aborted manually and restarted later.

Auditors are not quarantining objects written to a path with a different
partition power and therefore working as before (though they are reading
each object twice in the worst case before the no longer needed hard
links are removed).

Co-Authored-By: Alistair Coles <alistair.coles@hpe.com>
Co-Authored-By: Matthew Oliver <matt@oliver.net.au>
Co-Authored-By: Tim Burke <tim.burke@gmail.com>

[1] https://specs.openstack.org/openstack/swift-specs/specs/in_progress/
increasing_partition_power.html

Change-Id: I7d6371a04f5c1c4adbb8733a71f3c177ee5448bb
2017-06-15 15:08:48 -07:00
cheng
99412d4830 fix get ring name
replace ring_name = basename(ring_path)[:len('ring.gz')]
with ring_name = basename(ring_path)[:-len('.ring.gz')]

Change-Id: I741e46d116c8fc7c2e91a51da4284302eec3aa41
Closes-bug: #1668736
2017-03-18 03:43:32 +00:00
Sachin Patil
f713bb1352 Fix swift-get-nodes arg parsing for missing ring
- Verify .ring.gz path exist if ring file is the first argument.
- Code Refactoring:
  - swift/cli/info.parse_get_node_args()
  - Respective test cases for info.parse_get_node_args()

Closes-Bug: #1539275

Change-Id: I0a41936d6b75c60336be76f8702fd616d74f1545
Signed-off-by: Sachin Patil <psachin@redhat.com>
2017-02-06 07:57:12 +00:00
Ondřej Nový
9847796f01 Set owner of drive-audit recon cache to swift user
Fixies this problem:
* swift-drive-audit needs to be run by root, because only root have
  "umount" permission
* swift-object servers typically runs as user swift
* if swift-drive-audit is run by root, /var/cache/swift/drive.recon is
  owned by root, with 0o600
* recon middleware (inside swift-object-server) can't read this cache
  file: swift-object: Error reading recon cache file

This patch adds "user" option to drive-audit config file. Recon cache
is chowned to this user.

Change-Id: Ibf20543ee690b7c5a37fabd1540fd5c0c7b638c9
2016-10-19 17:16:42 +00:00
Stefan Majewsky
9d12575102 swift-recon-cron: do not get confused by files in /srv/node
swift-recon-cron looks at the drives mounted in directories below
/srv/node, but before this commit, it tried to call listdir() on
everything in this directory, even if it is not a directory.

Change-Id: Id281352f7ab6ecb520eb00f3649873d8c8678608
Signed-off-by: Stefan Majewsky <stefan.majewsky@sap.com>
2016-10-19 12:14:11 +02:00
Tim Burke
a741998bff Turn on F812 check
F812 list comprehension redefines <variable> from line ...

While the current violations were benign, this sort of code can easily
lead to subtle bugs. Seems worth checking, especially given how cheap it
is to bring existing code in line with it.

Change-Id: Ibdcf9f93b85a1f1411198001df6bdbfa8f92d114
2016-09-16 14:44:37 -07:00
Jenkins
18fa28c6c9 Merge "Deprecate swift-temp-url" 2016-09-02 20:21:57 +00:00
Christian Schwede
350f10bf3b Deprecate swift-temp-url
python-swiftclient includes an improved and tested method to generate
tempurls. The command syntax is essentially the same, therefore we can
deprecate this one by importing that method.

python-swiftclient is not added as a requirement; if the import fails
due to a missing swiftclient module it will just raise a deprecation
warning.

Closes-Bug: #1607523
Closes-Bug: #1607519

Change-Id: Ifa8bf636f20f82db4845b02d1b58699edaa39356
2016-09-02 06:13:08 +00:00
Thiago da Silva
05b8d9d7fc fix swift_oldies on RH based systems
Change-Id: Icbb4c6d461ded4fab2afade09e718b3a74917717
Signed-off-by: Thiago da Silva <thiago@redhat.com>
2016-08-11 16:24:57 -04:00
Jenkins
93cbd10b07 Merge "Make swift-oldies py3-compatible" 2016-08-09 19:48:17 +00:00
Ellen Leahy
7958638e8f Added quotes to example echo in swift-temp-url
If the curl command is used exactly as in the help, the ampersand
in the signature is interpreted as an operator and the curl
command breaks. I am aware of developers who have wasted a lot of
time because of this.

Change-Id: I6468c9a098b56db8242a2cf2c23b7a4857bd8574
2016-07-26 13:47:24 +00:00
Tim Burke
cdf505a50c Make swift-oldies py3-compatible
Change-Id: I0388f4738966bc453e922e9598ff9df60ecda4eb
2016-07-20 17:59:25 +00:00
Jenkins
1ac9ceb548 Merge "Add description of server options (all, main, rest) for swift-init help" 2016-07-08 23:31:20 +00:00
Mohit Motiani
6b6fa69349 Add description of server options (all, main, rest) for swift-init help
Running swift-init with -h, --help, or no arguments
displays help for the command. The help does not
document the 'main', 'all', and 'rest' options.
These are documented in the man page.

This patch adds all these server options in the
help of swift-init.

Change-Id: I8e27589912ae72ace14c955e66b86942bc23d9f7
Closes-Bug: #1580722
2016-07-08 13:53:46 -04:00
Tim Burke
9890184ea9 Turn on H233 and start using print function
As much as anything, I'm just tired of seeing a bunch or piecemeal
fixes.

Note that we *need* to include

   from __future__ import print_function

in order to support things like

   print()  # Would print "()" (the repr of an empty tuple) otherwise
   print(foo, end='')  # Would SyntaxError
   print(bar, file=sys.stderr)  # Would SyntaxError

Change-Id: I8fdf0740e292eb1ee785512d02e8c552781dcae1
2016-07-08 16:19:52 +00:00
Maria Malyarova
008a037a36 Another amendment with missing parenthesis
TrivialFix

Change-Id: Id44ae27bc39ea97be9eb092f8a99a06056b86392
2016-07-07 20:15:14 +03:00
Maria Malyarova
aa12901eda Added missing parenthesis in print calls
Upd. Import print_function from __future__
TrivialFix

Change-Id: Ibcda2c7e4ddbdff2420502dfd7d17db01f3c8056
2016-07-06 10:47:41 +00:00
Félix Cantournet
4f053c61d6 Fix swift-dispersion in multi-region setups
If you have 2 swift regions served by the same keystone,
then the client cannot get the correct URL for the swift endpoint
without specifying a region_name.

Closes-Bug: 1587088
Change-Id: Iaab883386e125c3ca6b9554389e63df17267a135
2016-06-01 15:35:47 +02:00
Jenkins
60c127575b Merge "swift-[account|container]-info when disk is full" 2016-04-22 17:31:09 +00:00
Nguyen Hung Phuong
59bbe27fb0 Fix typos in Swift files
Change-Id: I34e0c9a888127704ac1910e73ddd14e27ebade13
2016-03-30 04:15:23 +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
Jenkins
ebe61381c2 Merge "Keep the Usage of exit()/sys.exit() Consistent" 2016-02-18 14:26:49 +00:00
Jenkins
6a3b5f9aec Merge "Additional info log message for drive-audit" 2016-02-17 11:51:55 +00:00
Tomas Matlocha
d3dd137cad Additional info log message for drive-audit
An additional info log message was added for case of
running drive-audit without failed device unmounting.

Change-Id: I11abee40a712b6c6de65e63626b6f7f0a9c9f4c7
2016-02-12 11:26:16 +01:00
Mingyu Li
3b94bd4540 Keep the Usage of exit()/sys.exit() Consistent
It's better to keep the usage of exit()/sys.exit() consistent
in one file. Furthermore, sys.exit() is considered good to be
used in production code, while exit is for interactive shell.

Change-Id: Ia3092853a648922588e2bc11db37d6decdec1b48
2016-02-07 21:41:08 +08:00
Jenkins
dd405d9dd4 Merge "Fix ClientException handling in Container Sync" 2016-01-13 14:44:00 +00:00