From 5a0ead8cc88fd677d882391bddcff5b474a63a9b Mon Sep 17 00:00:00 2001 From: Pere Diaz Bou Date: Tue, 5 Jul 2022 12:39:12 +0200 Subject: [PATCH] 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 --- src/pybind/mgr/dashboard/services/rbd.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/pybind/mgr/dashboard/services/rbd.py b/src/pybind/mgr/dashboard/services/rbd.py index 07400651e42f1..ba2b5a747dc45 100644 --- a/src/pybind/mgr/dashboard/services/rbd.py +++ b/src/pybind/mgr/dashboard/services/rbd.py @@ -135,8 +135,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 @@ -368,7 +373,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 -- 2.39.5