Merge lp:~greglange/swift/lp754086 into lp:~hudson-openstack/swift/trunk

Proposed by Greg Lange
Status: Merged
Approved by: gholt
Approved revision: 266
Merged at revision: 273
Proposed branch: lp:~greglange/swift/lp754086
Merge into: lp:~hudson-openstack/swift/trunk
Diff against target: 46 lines (+19/-3)
1 file modified
bin/swauth-cleanup-tokens (+19/-3)
To merge this branch: bzr merge lp:~greglange/swift/lp754086
Reviewer Review Type Date Requested Status
Swift Core security contacts Pending
Review via email: mp+57385@code.launchpad.net

Commit message

swauth-cleanup-tokens now handles 404s on token containers and tokens better

To post a comment you must log in.
Revision history for this message
gholt (gholt) wrote :

*Do not approve until after Cactus release*

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/swauth-cleanup-tokens'
2--- bin/swauth-cleanup-tokens 2011-03-24 22:51:44 +0000
3+++ bin/swauth-cleanup-tokens 2011-04-12 19:22:26 +0000
4@@ -25,7 +25,7 @@
5 from sys import argv, exit
6 from time import sleep, time
7
8-from swift.common.client import Connection
9+from swift.common.client import Connection, ClientException
10
11
12 if __name__ == '__main__':
13@@ -65,7 +65,17 @@
14 while True:
15 if options.verbose:
16 print 'GET %s?marker=%s' % (container, marker)
17- objs = conn.get_container(container, marker=marker)[1]
18+ try:
19+ objs = conn.get_container(container, marker=marker)[1]
20+ except ClientException, e:
21+ if e.http_status == 404:
22+ print 'Container %s not found' % (container)
23+ print 'swauth-prep needs to be rerun'
24+ exit()
25+ else:
26+ print 'Object listing on container %s failed with ' \
27+ 'status code %d' % (container, e.http_status)
28+ break
29 if objs:
30 marker = objs[-1]['name']
31 else:
32@@ -90,7 +100,13 @@
33 (container, obj['name'],
34 time() - detail['expires'])
35 print 'DELETE %s/%s' % (container, obj['name'])
36- conn.delete_object(container, obj['name'])
37+ try:
38+ conn.delete_object(container, obj['name'])
39+ except ClientException, e:
40+ if e.http_status != 404:
41+ print 'DELETE of %s/%s failed with status ' \
42+ 'code %d' % (container, obj['name'],
43+ e.http_status)
44 elif options.verbose:
45 print "%s/%s won't expire for %ds; skipping" % \
46 (container, obj['name'],