From f4f25fde54c35955ad85fafa8de3a5d99931c94e Mon Sep 17 00:00:00 2001 From: hsiang41 Date: Mon, 12 Nov 2018 22:43:49 +0800 Subject: [PATCH] mgr: Fixed devicehealth plugin resource leak The devicehealth plugin not close rados connection at show device metrics function. Signed-off-by: Rick Chen --- src/pybind/mgr/devicehealth/module.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pybind/mgr/devicehealth/module.py b/src/pybind/mgr/devicehealth/module.py index f2dd5368e3a..aa684225c70 100644 --- a/src/pybind/mgr/devicehealth/module.py +++ b/src/pybind/mgr/devicehealth/module.py @@ -400,7 +400,9 @@ class Module(MgrModule): # fetch metrics res = {} ioctx = self.open_connection(create_if_missing=False) - if ioctx: + if not ioctx: + return 0, json.dumps(res, indent=4), '' + with ioctx: with rados.ReadOpCtx() as op: omap_iter, ret = ioctx.get_omap_vals(op, "", sample or '', 500) # fixme assert ret == 0