Skip to content

Module 'ceph_add_users_buckets.py' didn't catch the right exception #13

@wissemmimouna

Description

@wissemmimouna

Hi ,

I figured out a little typo in the module 'ceph_add_users_buckets.py' when you create a bucket , it doesn't catch the right exception 'radosgw.exception.NoSuchBucket' it only catch the 'TypeError' Exception which cause the module to fail if we try to create a new bucket with the error 'radosgw.exception.NoSuchBucket: NoSuchBucket (404 Not Found)' .

Here below the simple fix suggested on the file ' ceph_add_users_buckets.py ' (just catch the NoSuchBucket Exception)==>

def create_buckets(rgw, buckets, result):
 ...

     for bucket_info in buckets:
         bucket = bucket_info['bucket']
         user = bucket_info['user']

         #  check if bucket exists
         try:
             bucket_info = rgw.get_bucket(bucket_name=bucket)
         except TypeError:
             # it doesnt exist
             bucket_info = None
**     except radosgw.exception.NoSuchBucket:                                                                                                            
             bucket_info = None    **
 
         # if it exists add to failed list
         if bucket_info: 
             failed_buckets.append(bucket)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions