Project

General

Profile

Actions

Cleanup #63421

closed

pybind/mgr: remove bogus __del__() methods of python mgr modules

Added by Ramana Raja 6 months ago. Updated about 2 months ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
-
Target version:
-
% Done:

0%

Tags:
Backport:
Reviewed:
Affected Versions:
Pull request ID:

Description

From https://github.com/ceph/ceph/pull/54251#discussion_r1378165335,
"
What I don't understand there is why in https://github.com/ceph/ceph/pull/30890 it was deemed necessary to call `VolumeClient.shutdown()` from both `Module.shutdown()` and `Module.__del__()`. It doesn't make sense to me because:
- `Module.__del__()` would end up doing shutdown work only if the last reference to `Module` somehow got put without `Module.shutdown()` being called first. Otherwise there would be no shutdown work to do.
- It's the manager framework who was expected to call `Module.shutdown()` from C++ via `PyModuleRunner::shutdown()`.
- It's the (same) manager framework who is holding at least one reference to `Module`.

So either I'm missing something, or all `__del__()` methods in modules (`MgrModule` subclasses) where something is closed or "shut down" are bogus. `__del__()` isn't even guaranteed to be called:

https://docs.python.org/3.11/reference/datamodel.html

An implementation is allowed to postpone garbage collection or omit it altogether — it is a matter of implementation quality how garbage collection is implemented [...]

[...] Do not depend on immediate finalization of objects when they become unreachable (so you should always close files explicitly)."

Also observed that in
- mgr/mgr_module.py, MgrModule.__del__() and MgrStandbyModule.__del__() call `MgrModuleLoggingMixin.unconfigure_logging()`, which is also called in `MgrModuleLoggingMixin._configure_logging()`
- mgr/telegraf/basesocket.py, BaseSocket.__del__() tries to close a socket. The socket is also closed by BaseSocker.__exit__()

Actions #1

Updated by Ramana Raja 6 months ago

  • Description updated (diff)
Actions #2

Updated by Ramana Raja 6 months ago

  • Status changed from New to In Progress
  • Assignee set to Ramana Raja
Actions #3

Updated by Ilya Dryomov 6 months ago

  • Status changed from In Progress to Fix Under Review
  • Pull request ID set to 54375
Actions #4

Updated by Ramana Raja about 2 months ago

  • Status changed from Fix Under Review to Resolved
Actions

Also available in: Atom PDF