From: Pere Diaz Bou Date: Tue, 5 Jul 2022 10:39:12 +0000 (+0200) Subject: mgr/dashboard: RbdConfiguration.list reuse image context. X-Git-Tag: v16.2.11~407^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3c3813bfd746ca4f0d96828548d638451b9f9c39;p=ceph.git mgr/dashboard: RbdConfiguration.list reuse image context. Image contexts are reopen even though we pass the context as an argument. This commit changes that so you can forget about reopening a rbd image context again. Signed-off-by: Pere Diaz Bou (cherry picked from commit 5a0ead8cc88fd677d882391bddcff5b474a63a9b) --- diff --git a/src/pybind/mgr/dashboard/services/rbd.py b/src/pybind/mgr/dashboard/services/rbd.py index da3bb056bee..d35a99e97a3 100644 --- a/src/pybind/mgr/dashboard/services/rbd.py +++ b/src/pybind/mgr/dashboard/services/rbd.py @@ -156,8 +156,13 @@ class RbdConfiguration(object): def _list(ioctx): if self._image_name: # image config try: - with rbd.Image(ioctx, self._image_name) as image: - result = image.config_list() + # No need to open the context of the image again + # if we already did open it. + if self._image_ioctx: + result = self._image_ioctx.config_list() + else: + with rbd.Image(ioctx, self._image_name) as image: + result = image.config_list() except rbd.ImageNotFound: result = [] else: # pool config @@ -387,7 +392,8 @@ class RbdService(object): stat['total_disk_usage'] = None stat['disk_usage'] = None - stat['configuration'] = RbdConfiguration(pool_ioctx=ioctx, image_name=image_name).list() + stat['configuration'] = RbdConfiguration( + pool_ioctx=ioctx, image_name=image_name, image_ioctx=img).list() return stat