Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify the RBD image handling in create namespace #671

Merged
merged 1 commit into from
May 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions control/cephutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,10 @@ def get_image_size(self, pool_name, image_name) -> int:
with cluster.open_ioctx(pool_name) as ioctx:
rbd_inst = rbd.RBD()
try:
images = rbd_inst.list(ioctx)
if image_name in images:
try:
with rbd.Image(ioctx, image_name) as img:
img_stat = img.stat()
image_size = img_stat["size"]
except Exception as ex:
self.logger.exception(f"Can't get image object for {pool_name}/{image_name}")
raise ex
else:
raise rbd.ImageNotFound(f"Image {pool_name}/{image_name} doesn't exist", errno = errno.ENODEV)
with rbd.Image(ioctx, image_name) as img:
image_size = img.size()
except rbd.ImageNotFound:
raise rbd.ImageNotFound(f"Image {pool_name}/{image_name} doesn't exist", errno = errno.ENODEV)
except Exception as ex:
self.logger.exception(f"Error while trying to get the size of image {pool_name}/{image_name}")
raise ex
Expand Down
Loading