]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: RbdConfiguration.list reuse image context.
authorPere Diaz Bou <pdiazbou@redhat.com>
Tue, 5 Jul 2022 10:39:12 +0000 (12:39 +0200)
committerPere Diaz Bou <pdiazbou@redhat.com>
Thu, 14 Jul 2022 15:28:27 +0000 (17:28 +0200)
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 <pdiazbou@redhat.com>
(cherry picked from commit 5a0ead8cc88fd677d882391bddcff5b474a63a9b)

src/pybind/mgr/dashboard/services/rbd.py

index da3bb056beeb052923d26376a8a1e260c47b812e..d35a99e97a3b2425b68a357acb92831bc527d61d 100644 (file)
@@ -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