Merge "dispersion report option to output missing parts"
This commit is contained in:
commit
13941cb8eb
@ -67,7 +67,7 @@ def get_error_log(prefix):
|
||||
|
||||
|
||||
def container_dispersion_report(coropool, connpool, account, container_ring,
|
||||
retries):
|
||||
retries, output_missing_partitions):
|
||||
with connpool.item() as conn:
|
||||
containers = [c['name'] for c in conn.get_account(
|
||||
prefix='dispersion_', full_listing=True)[1]]
|
||||
@ -100,6 +100,13 @@ def container_dispersion_report(coropool, connpool, account, container_ring,
|
||||
except (Exception, Timeout), err:
|
||||
error_log('Giving up on /%s/%s/%s: %s' % (part, account,
|
||||
container, err))
|
||||
if output_missing_partitions and \
|
||||
found_count < container_ring.replica_count:
|
||||
missing = container_ring.replica_count - found_count
|
||||
print '\r\x1B[K',
|
||||
stdout.flush()
|
||||
print >>stderr, '# Container partition %s missing %s cop%s' % (
|
||||
part, missing, 'y' if missing == 1 else 'ies')
|
||||
container_copies_found[found_count] += 1
|
||||
containers_queried[0] += 1
|
||||
if time() >= next_report[0]:
|
||||
@ -156,7 +163,7 @@ def container_dispersion_report(coropool, connpool, account, container_ring,
|
||||
|
||||
|
||||
def object_dispersion_report(coropool, connpool, account, object_ring,
|
||||
retries):
|
||||
retries, output_missing_partitions):
|
||||
container = 'dispersion_objects'
|
||||
with connpool.item() as conn:
|
||||
try:
|
||||
@ -198,6 +205,13 @@ def object_dispersion_report(coropool, connpool, account, object_ring,
|
||||
except (Exception, Timeout), err:
|
||||
error_log('Giving up on /%s/%s/%s/%s: %s' % (part, account,
|
||||
container, obj, err))
|
||||
if output_missing_partitions and \
|
||||
found_count < object_ring.replica_count:
|
||||
missing = object_ring.replica_count - found_count
|
||||
print '\r\x1B[K',
|
||||
stdout.flush()
|
||||
print >>stderr, '# Object partition %s missing %s cop%s' % (
|
||||
part, missing, 'y' if missing == 1 else 'ies')
|
||||
object_copies_found[found_count] += 1
|
||||
objects_queried[0] += 1
|
||||
if time() >= next_report[0]:
|
||||
@ -289,6 +303,8 @@ Usage: %prog [options] [conf_file]
|
||||
help='dump dispersion report in json format')
|
||||
parser.add_option('-d', '--debug', action='store_true', default=False,
|
||||
help='print 404s to standard error')
|
||||
parser.add_option('-p', '--partitions', action='store_true', default=False,
|
||||
help='print missing partitions to standard error')
|
||||
|
||||
options, args = parser.parse_args()
|
||||
|
||||
@ -323,11 +339,11 @@ Usage: %prog [options] [conf_file]
|
||||
container_ring = Ring(swift_dir, ring_name='container')
|
||||
object_ring = Ring(swift_dir, ring_name='object')
|
||||
|
||||
container_result = container_dispersion_report(coropool, connpool,
|
||||
account, container_ring,
|
||||
retries)
|
||||
object_result = object_dispersion_report(coropool, connpool, account,
|
||||
object_ring, retries)
|
||||
container_result = container_dispersion_report(
|
||||
coropool, connpool, account, container_ring, retries,
|
||||
options.partitions)
|
||||
object_result = object_dispersion_report(
|
||||
coropool, connpool, account, object_ring, retries, options.partitions)
|
||||
if json_output:
|
||||
print json.dumps({"container": container_result,
|
||||
"object": object_result})
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
.SH SYNOPSIS
|
||||
.LP
|
||||
.B swift-dispersion-report [-j|--dump-json] [conf_file]
|
||||
.B swift-dispersion-report [-d|--debug] [-j|--dump-json] [-p|--partitions] [conf_file]
|
||||
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
@ -54,12 +54,24 @@ same configuration file, /etc/swift/dispersion.conf . The account used by these
|
||||
tool should be a dedicated account for the dispersion stats and also have admin
|
||||
privileges.
|
||||
|
||||
.SH OPTIONS
|
||||
.RS 0
|
||||
.PD 1
|
||||
.IP "\fB-d, --debug\fR"
|
||||
output any 404 responses to standard error
|
||||
|
||||
.SH OPTIONS
|
||||
.RS 0
|
||||
.PD 1
|
||||
.IP "\fB-j, --dump-json\fR"
|
||||
output dispersion report in json format
|
||||
|
||||
.SH OPTIONS
|
||||
.RS 0
|
||||
.PD 1
|
||||
.IP "\fB-p, --partitions\fR"
|
||||
output the partition numbers that have any missing replicas
|
||||
|
||||
.SH CONFIGURATION
|
||||
.PD 0
|
||||
Example \fI/etc/swift/dispersion.conf\fR:
|
||||
|
Loading…
Reference in New Issue
Block a user