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

mimic: rbd: API list_images() Segmentation fault #26707

Merged
merged 2 commits into from Mar 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/librbd/librbd.cc
Expand Up @@ -4711,6 +4711,7 @@ extern "C" int rbd_group_image_list(rados_ioctx_t group_p,

if (r == -ENOENT) {
tracepoint(librbd, group_image_list_exit, 0);
*image_size = 0;
return 0;
}

Expand Down
6 changes: 6 additions & 0 deletions src/pybind/rbd/rbd.pyx
Expand Up @@ -1615,6 +1615,12 @@ cdef class Group(object):
self._ioctx = convert_ioctx(ioctx)
self._name = name

def __enter__(self):
return self

def __exit__(self, type_, value, traceback):
return False

def add_image(self, image_ioctx, image_name):
"""
Add an image to a group.
Expand Down
10 changes: 10 additions & 0 deletions src/test/pybind/test_rbd.py
Expand Up @@ -1825,6 +1825,16 @@ def test_group_image_list(self):
self.group.add_image(ioctx, image_name)
eq([image_name], [img['name'] for img in self.group.list_images()])

def test_group_image_list_move_to_trash(self):
eq([], list(self.group.list_images()))
with Image(ioctx, image_name) as image:
image_id = image.id()
self.group.add_image(ioctx, image_name)
eq([image_name], [img['name'] for img in self.group.list_images()])
RBD().trash_move(ioctx, image_name, 0)
eq([], list(self.group.list_images()))
RBD().trash_restore(ioctx, image_id, image_name)

def test_group_image_many_images(self):
eq([], list(self.group.list_images()))
self.group.add_image(ioctx, image_name)
Expand Down