mirror of
https://github.com/ceph/s3-tests.git
synced 2024-11-25 03:47:22 +00:00
s3tests: cleanup, set bucket acls if permission denied
retry bucket removal after setting the bucket permissions if we're
getting pemission denied. This will make sure the bucket gets removed.
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
(cherry picked from commit c41ebab9cf
)
This commit is contained in:
parent
366fdee269
commit
5d72a43ffa
1 changed files with 25 additions and 17 deletions
|
@ -64,8 +64,9 @@ def nuke_prefixed_buckets_on_conn(prefix, name, conn):
|
|||
print 'prefix=',prefix
|
||||
if bucket.name.startswith(prefix):
|
||||
print 'Cleaning bucket {bucket}'.format(bucket=bucket)
|
||||
success = False
|
||||
for i in xrange(2):
|
||||
try:
|
||||
# bucket.set_canned_acl('private')
|
||||
for key in bucket.list_versions():
|
||||
print 'Cleaning bucket {bucket} key {key}'.format(
|
||||
bucket=bucket,
|
||||
|
@ -74,13 +75,21 @@ def nuke_prefixed_buckets_on_conn(prefix, name, conn):
|
|||
# key.set_canned_acl('private')
|
||||
bucket.delete_key(key.name, version_id = key.version_id)
|
||||
bucket.delete()
|
||||
success = True
|
||||
except boto.exception.S3ResponseError as e:
|
||||
if e.error_code != 'AccessDenied':
|
||||
print 'GOT UNWANTED ERROR', e.error_code
|
||||
raise
|
||||
# seems like we're not the owner of the bucket; ignore
|
||||
# seems like we don't have permissions set appropriately, we'll
|
||||
# modify permissions and retry
|
||||
pass
|
||||
|
||||
if success:
|
||||
return
|
||||
|
||||
bucket.set_canned_acl('private')
|
||||
|
||||
|
||||
def nuke_prefixed_buckets(prefix):
|
||||
# If no regions are specified, use the simple method
|
||||
if targets.main.master == None:
|
||||
|
@ -106,7 +115,6 @@ def nuke_prefixed_buckets(prefix):
|
|||
|
||||
print 'Done with cleanup of test buckets.'
|
||||
|
||||
|
||||
class TargetConfig:
|
||||
def __init__(self, cfg, section):
|
||||
self.port = None
|
||||
|
|
Loading…
Reference in a new issue