]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
pybind/mgr: remove __del__() of mgr modules 54375/head
authorRamana Raja <rraja@redhat.com>
Thu, 2 Nov 2023 21:44:10 +0000 (17:44 -0400)
committerRamana Raja <rraja@redhat.com>
Mon, 13 Nov 2023 16:07:40 +0000 (11:07 -0500)
commit6d8e0a82f6e6bb6a5d7833fa431b750c1b17b644
tree8b3eba461fdadadb20ee37dd9618cfee3cf0a81f
parent50ff870c24481d820efa3396a38402f36e17df82
pybind/mgr: remove __del__() of mgr modules

It's strongly recommended for objects that have references to
external resources (e.g., files) to explicitly release them.
Python doesn't guarantee garbage collection of objects and hence
doesn't guarantee freeing of external resources that occur on
garbage collection.

The __del__() methods in the python mgr modules may not even be
called since garbage collection of objects is not guaranteed in python.
And some of the __del__() methods try to cleanup that seem redundant.

- In volumes/module.py, vc.shutdown() is called in Module.shutdown().
  No need to call it again in Module.__del__()

- In telegraf/basesocket.py, BaseSocker.close() is called in
  BaseSocket.__exit__(). No need to call it again in
  BaseSocket.__del__().

- In mgr_module.py, MgrModuleLoggingMixin._unconfigure_logging() is
  called in MgrModule.__init__() and MgrStandbyModule.__init__(). No
  need to call it in MgrModule.__del__() and
  MgrStandbyModule.__del__().|

- In dashboard/services/cephfs.py, the libcephfs mount is not
  shutdown explicitly by the mgr module. However, the cython libcephfs
  bindings has a LibCephFS.__dealloc__() finalizer method that calls
  LibCephFS.shutdown(). This should unmount and cleanup the ceph mount
  handle.

Remove the __del__() of the python mgr modules.

Fixes: https://tracker.ceph.com/issues/63421
Signed-off-by: Ramana Raja <rraja@redhat.com>
src/pybind/mgr/dashboard/services/cephfs.py
src/pybind/mgr/mgr_module.py
src/pybind/mgr/telegraf/basesocket.py
src/pybind/mgr/volumes/module.py