swauth-cleanup-tokens now handles 404s on token containers and tokens better
This commit is contained in:
@@ -25,7 +25,7 @@ from optparse import OptionParser
|
||||
from sys import argv, exit
|
||||
from time import sleep, time
|
||||
|
||||
from swift.common.client import Connection
|
||||
from swift.common.client import Connection, ClientException
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
@@ -65,7 +65,17 @@ if __name__ == '__main__':
|
||||
while True:
|
||||
if options.verbose:
|
||||
print 'GET %s?marker=%s' % (container, marker)
|
||||
objs = conn.get_container(container, marker=marker)[1]
|
||||
try:
|
||||
objs = conn.get_container(container, marker=marker)[1]
|
||||
except ClientException, e:
|
||||
if e.http_status == 404:
|
||||
print 'Container %s not found' % (container)
|
||||
print 'swauth-prep needs to be rerun'
|
||||
exit()
|
||||
else:
|
||||
print 'Object listing on container %s failed with ' \
|
||||
'status code %d' % (container, e.http_status)
|
||||
break
|
||||
if objs:
|
||||
marker = objs[-1]['name']
|
||||
else:
|
||||
@@ -90,7 +100,13 @@ if __name__ == '__main__':
|
||||
(container, obj['name'],
|
||||
time() - detail['expires'])
|
||||
print 'DELETE %s/%s' % (container, obj['name'])
|
||||
conn.delete_object(container, obj['name'])
|
||||
try:
|
||||
conn.delete_object(container, obj['name'])
|
||||
except ClientException, e:
|
||||
if e.http_status != 404:
|
||||
print 'DELETE of %s/%s failed with status ' \
|
||||
'code %d' % (container, obj['name'],
|
||||
e.http_status)
|
||||
elif options.verbose:
|
||||
print "%s/%s won't expire for %ds; skipping" % \
|
||||
(container, obj['name'],
|
||||
|
||||
Reference in New Issue
Block a user