forked from TrueCloudLab/s3-tests
Fall back when nuking buckets
Some S3 implementations do not support object versioning - fall back to listing without versions. Signed-off-by: Andrew Gaul <andrew@gaul.org>
This commit is contained in:
parent
c41ebab9cf
commit
0dfcbc7da6
1 changed files with 11 additions and 1 deletions
|
@ -67,7 +67,17 @@ def nuke_prefixed_buckets_on_conn(prefix, name, conn):
|
|||
success = False
|
||||
for i in xrange(2):
|
||||
try:
|
||||
for key in bucket.list_versions():
|
||||
try:
|
||||
iterator = iter(bucket.list_versions())
|
||||
# peek into iterator to issue list operation
|
||||
keys = itertools.chain([next(iterator)], iterator)
|
||||
except boto.exception.S3ResponseError as e:
|
||||
# some S3 implementations do not support object
|
||||
# versioning - fall back to listing without versions
|
||||
if e.error_code != 'NotImplemented':
|
||||
raise e
|
||||
keys = bucket.list();
|
||||
for key in keys:
|
||||
print 'Cleaning bucket {bucket} key {key}'.format(
|
||||
bucket=bucket,
|
||||
key=key,
|
||||
|
|
Loading…
Reference in a new issue