ceph / ceph/ceph.automation

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

Open
#13 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
10
Forks
17
PR merge metrics
No merged PRs in 30d

Description

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)
```

Contributor guide

Open the contributing guide

Research direction

Open ceph_add_users_buckets.py and start at create_buckets, especially the rgw.get_bucket call and its exception handling. Confirm the bucket-creation path treats radosgw.exception.NoSuchBucket as a missing bucket, then verify that creating a new bucket no longer fails with the reported 404 error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devops
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.