added printing of 404s to dispersion report; fixed small, unrelated bug

also fixed bug where in error_log where identifier wasn't being set to anything meaningful, set it to the right thing

bug 612722

Change-Id: I53f237ea0db2a5b2b8979a7b41189faf1275e861
This commit is contained in:
Greg Lange
2012-06-06 19:57:04 +00:00
parent f7757e4ebf
commit 27455cb15b

View File

@@ -34,23 +34,29 @@ from swift.common.utils import compute_eta, get_time_units, TRUE_VALUES
unmounted = [] unmounted = []
notfound = []
json_output = False json_output = False
debug = False
def get_error_log(prefix): def get_error_log(prefix):
def error_log(msg_or_exc): def error_log(msg_or_exc):
global unmounted global debug, unmounted, notfound
if hasattr(msg_or_exc, 'http_status') and \ if hasattr(msg_or_exc, 'http_status'):
msg_or_exc.http_status == 507: identifier = '%s:%s/%s' % (msg_or_exc.http_host,
identifier = '%s:%s/%s' msg_or_exc.http_port, msg_or_exc.http_device)
if identifier not in unmounted: if msg_or_exc.http_status == 507:
unmounted.append(identifier) if identifier not in unmounted:
print >>stderr, 'ERROR: %s:%s/%s is unmounted -- This will ' \ unmounted.append(identifier)
'cause replicas designated for that device to be ' \ print >>stderr, 'ERROR: %s is unmounted -- This will ' \
'considered missing until resolved or the ring is ' \ 'cause replicas designated for that device to be ' \
'updated.' % (msg_or_exc.http_host, msg_or_exc.http_port, 'considered missing until resolved or the ring is ' \
msg_or_exc.http_device) 'updated.' % (identifier)
stderr.flush()
if debug and identifier not in notfound:
notfound.append(identifier)
print >>stderr, 'ERROR: %s returned a 404' % (identifier)
stderr.flush() stderr.flush()
if not hasattr(msg_or_exc, 'http_status') or \ if not hasattr(msg_or_exc, 'http_status') or \
msg_or_exc.http_status not in (404, 507): msg_or_exc.http_status not in (404, 507):
@@ -260,6 +266,8 @@ Usage: %prog [options] [conf_file]
[conf_file] defaults to /etc/swift/stats.conf'''.strip()) [conf_file] defaults to /etc/swift/stats.conf'''.strip())
parser.add_option('-j', '--dump-json', action='store_true', default=False, parser.add_option('-j', '--dump-json', action='store_true', default=False,
help='dump dispersion report in json format') help='dump dispersion report in json format')
parser.add_option('-d', '--debug', action='store_true', default=False,
help='print 404s to standard error')
options, args = parser.parse_args() options, args = parser.parse_args()
@@ -277,6 +285,8 @@ Usage: %prog [options] [conf_file]
concurrency = int(conf.get('concurrency', 25)) concurrency = int(conf.get('concurrency', 25))
if options.dump_json or conf.get('dump_json', 'no').lower() in TRUE_VALUES: if options.dump_json or conf.get('dump_json', 'no').lower() in TRUE_VALUES:
json_output = True json_output = True
if options.debug:
debug = True
coropool = GreenPool(size=concurrency) coropool = GreenPool(size=concurrency)