Skip to content

mgr: add config to load modules in main interpreter instead of subinterpreter - #66244

Merged
batrick merged 5 commits into
ceph:mainfrom
athanatos:wip-sjust-for-review-subinterpreter-config
Mar 20, 2026
Merged

batrick merged 5 commits into
ceph:mainfrom
athanatos:wip-sjust-for-review-subinterpreter-config

Conversation

@athanatos

Copy link
Copy Markdown
Contributor
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

@github-actions

Copy link
Copy Markdown

Config Diff Tool Output

+ added: mgr_main_interpreter_modules (mgr.yaml.in)

The above configuration changes are found in the PR. Please update the relevant release documentation if necessary.
Ignore this comment if docs are already updated. To make the "Check ceph config changes" CI check pass, please comment /config check ok and re-run the test.

@athanatos

Copy link
Copy Markdown
Contributor Author

Replaces #66176

@athanatos

Copy link
Copy Markdown
Contributor Author

/config check ok

@yaarith

yaarith commented Nov 14, 2025

Copy link
Copy Markdown
Contributor

depends on #66240

@athanatos

Copy link
Copy Markdown
Contributor Author

https://tracker.ceph.com/issues/73857 suggests that rbd_support needs to be in the main interpreter as well due to librbd/librados python bindings misbehaving. Perhaps the right choice would be to default modules into the main interpreter and make the config selectively move them into a subinterpreter? @cbodley @batrick @NitzanMordhai ?

@idryomov

Copy link
Copy Markdown
Contributor

I have just asked this in https://tracker.ceph.com/issues/73857, but may get more eyes here: what was the actual problem that sub-interpreters were supposed to solve?

@athanatos
athanatos force-pushed the wip-sjust-for-review-subinterpreter-config branch 2 times, most recently from d7b7361 to 2b3e1be Compare November 14, 2025 21:59
@athanatos

Copy link
Copy Markdown
Contributor Author

@idryomov That really is not clear to me. I think the idea was to provide isolation, but I don't think they ever actually did to any real degree. At this point, I think the question is moot until we have a reason to put effort into reenabling them (such as letting subinterpreters have distinct gils).

@athanatos
athanatos force-pushed the wip-sjust-for-review-subinterpreter-config branch 2 times, most recently from 6531997 to a39c387 Compare November 15, 2025 00:01
@athanatos
athanatos marked this pull request as draft November 15, 2025 02:10
@athanatos

Copy link
Copy Markdown
Contributor Author

Marking back to draft for now. I see a potential problem with how MgrModule works -- MgrModule.COMMANDS seems like it'll end up with the command set for all modules in the same interpreter. I need to look into this more on Monday, might just be misunderstanding how it works.

@NitzanMordhai

Copy link
Copy Markdown
Contributor

@athanatos i tried that code, it will load all modules into the main interpreter, which causes slow responses from any cli commands

@NitzanMordhai

Copy link
Copy Markdown
Contributor

@athanatos I'm adding here example:
nmordech@folio03  ~/ceph/build   check-main-intertpreter-load  ceph config set mgr mgr_subinterpreter_modules "*"
2025-11-17T17:28:45.333+0000 7efc6e26c640 -1 WARNING: all dangerous and experimental features are enabled.
2025-11-17T17:28:45.371+0000 7efc6e26c640 -1 WARNING: all dangerous and experimental features are enabled.
nmordech@folio03  ~/ceph/build   check-main-intertpreter-load  ceph mgr fail
2025-11-17T17:29:07.070+0000 7fa73913e640 -1 WARNING: all dangerous and experimental features are enabled.
2025-11-17T17:29:07.096+0000 7fa73913e640 -1 WARNING: all dangerous and experimental features are enabled.
nmordech@folio03  ~/ceph/build   check-main-intertpreter-load  time ceph osd tree
2025-11-17T17:29:43.360+0000 7f78967b5640 -1 WARNING: all dangerous and experimental features are enabled.
2025-11-17T17:29:43.385+0000 7f78967b5640 -1 WARNING: all dangerous and experimental features are enabled.
ID CLASS WEIGHT TYPE NAME STATUS REWEIGHT PRI-AFF
-1 0.09859 root default
-3 0.09859 host folio03
0 ssd 0.09859 osd.0 up 1.00000 1.00000
ceph osd tree 0.46s user 0.09s system 95% cpu 0.575 total
nmordech@folio03  ~/ceph/build   check-main-intertpreter-load  ceph config set mgr mgr_subinterpreter_modules ""
2025-11-17T17:29:50.294+0000 7f776a8b0640 -1 WARNING: all dangerous and experimental features are enabled.
2025-11-17T17:29:50.332+0000 7f776a8b0640 -1 WARNING: all dangerous and experimental features are enabled.
nmordech@folio03  ~/ceph/build   check-main-intertpreter-load  ceph mgr fail
2025-11-17T17:29:54.221+0000 7f015cf76640 -1 WARNING: all dangerous and experimental features are enabled.
2025-11-17T17:29:54.247+0000 7f015cf76640 -1 WARNING: all dangerous and experimental features are enabled.
nmordech@folio03  ~/ceph/build   check-main-intertpreter-load  time ceph osd tree
2025-11-17T17:29:57.632+0000 7f8ba54b7640 -1 WARNING: all dangerous and experimental features are enabled.
2025-11-17T17:29:57.658+0000 7f8ba54b7640 -1 WARNING: all dangerous and experimental features are enabled.
ID CLASS WEIGHT TYPE NAME STATUS REWEIGHT PRI-AFF
-1 0.09859 root default
-3 0.09859 host folio03
0 ssd 0.09859 osd.0 up 1.00000 1.00000
ceph osd tree 15.55s user 0.76s system 92% cpu 17.649 total

you can see that when mgr mgr_subinterpreter_modules = "" (the default) it took 17.6 seconds (it can happened for any command)
when i start all modules under its own subinterpreter cli commands takes: 0.5 seconds

@batrick

batrick commented Nov 17, 2025

Copy link
Copy Markdown
Member

@athanatos

Copy link
Copy Markdown
Contributor Author

@NitzanMordhai Good observation. I think it's related to the MgrModule.COMMANDS behavior I mentioned above -- I think the mgr is querying every module for every command. Will investigate.

NitzanMordhai added a commit to NitzanMordhai/ceph that referenced this pull request Feb 12, 2026
After PR ceph#66244, all mgr modules run inside the same Python interpreter.
That means they also share the same logging subsystem.
Previously, each module attached its handlers to the root logger. In practice,
whichever module initialized logging last effectively “owned” the root logger,
and log messages from other modules could end up attributed incorrectly.

This change scopes logging per module. Each module now registers its handlers
on a dedicated logger named after the module itself, with propagate=False to avoid
leaking messages into the root logger.

Now, the getLogger() default (no args) returns the module's named logger
rather than the root logger. This ensures self.log routes correctly.

Fixes: https://tracker.ceph.com/issues/74848
Signed-off-by: Nitzan Mordechai <[email protected]>
batrick added a commit to batrick/ceph that referenced this pull request Feb 12, 2026
* refs/pull/66244/head:
	mgr/Gil.cc: simplify Gil(), ~Gil()
	mgr/Gil.cc: do not use PyGILState_Check()
	mgr: add mgr_subinterpreter_modules config
	python-common/.../service_spec: implement ServiceSpec.__getnewargs__ to allow unpickle to work correctly
	mgr: serialize python objects sent between subinterpreters via remote
NitzanMordhai added a commit to NitzanMordhai/ceph that referenced this pull request Feb 15, 2026
After PR ceph#66244, all mgr modules run inside the same Python interpreter.
That means they also share the same logging subsystem.
Previously, each module attached its handlers to the root logger. In practice,
whichever module initialized logging last effectively “owned” the root logger,
and log messages from other modules could end up attributed incorrectly.

This change scopes logging per module. Each module now registers its handlers
on a dedicated logger named after the module itself, with propagate=False to avoid
leaking messages into the root logger.

Now, the getLogger() default (no args) returns the module's named logger
rather than the root logger. This ensures self.log routes correctly.

Fixes: https://tracker.ceph.com/issues/74848
Signed-off-by: Nitzan Mordechai <[email protected]>
NitzanMordhai pushed a commit to NitzanMordhai/ceph that referenced this pull request Feb 17, 2026
as the modules are now being loaded onto the main interpreter (see
ceph#66244), the
cherrypy is getting hit with an issue where its global state is being
affecting all the modules updating the cherrypy config simultaneously in
the same tree.

So i am adding a CherryPyMgr which manages all the independent servers
that will be created across all modules. This CherryPyMgr will create
its own server instances by utilizing cherrypy's WSGI Server and
eliminates the global state sharing. Each module or app can create their
own tree and start an adapter which will open an independent server for
that app.

- also added a method to update the config in place so CORS urls can be
  configured without restarting servers.

Fixes: https://tracker.ceph.com/issues/74643, https://tracker.ceph.com/issues/74543
Signed-off-by: Nizamudeen A <[email protected]>
NitzanMordhai added a commit to NitzanMordhai/ceph that referenced this pull request Feb 17, 2026
After PR ceph#66244, all mgr modules run inside the same Python interpreter.
That means they also share the same logging subsystem.
Previously, each module attached its handlers to the root logger. In practice,
whichever module initialized logging last effectively “owned” the root logger,
and log messages from other modules could end up attributed incorrectly.

This change scopes logging per module. Each module now registers its handlers
on a dedicated logger named after the module itself, with propagate=False to avoid
leaking messages into the root logger.

Now, the getLogger() default (no args) returns the module's named logger
rather than the root logger. This ensures self.log routes correctly.

Fixes: https://tracker.ceph.com/issues/74848
Signed-off-by: Nitzan Mordechai <[email protected]>
NitzanMordhai pushed a commit to ceph/ceph-ci that referenced this pull request Feb 18, 2026
as the modules are now being loaded onto the main interpreter (see
ceph/ceph#66244), the
cherrypy is getting hit with an issue where its global state is being
affecting all the modules updating the cherrypy config simultaneously in
the same tree.

So i am adding a CherryPyMgr which manages all the independent servers
that will be created across all modules. This CherryPyMgr will create
its own server instances by utilizing cherrypy's WSGI Server and
eliminates the global state sharing. Each module or app can create their
own tree and start an adapter which will open an independent server for
that app.

- also added a method to update the config in place so CORS urls can be
  configured without restarting servers.

Fixes: https://tracker.ceph.com/issues/74643, https://tracker.ceph.com/issues/74543
Signed-off-by: Nizamudeen A <[email protected]>
NitzanMordhai added a commit to NitzanMordhai/ceph that referenced this pull request Feb 19, 2026
After PR ceph#66244, all mgr modules run inside the same Python interpreter.
That means they also share the same logging subsystem.
Previously, each module attached its handlers to the root logger. In practice,
whichever module initialized logging last effectively “owned” the root logger,
and log messages from other modules could end up attributed incorrectly.

This change scopes logging per module. Each module now registers its handlers
on a dedicated logger named after the module itself, with propagate=False to avoid
leaking messages into the root logger.

Now, the getLogger() default (no args) returns the module's named logger
rather than the root logger. This ensures self.log routes correctly.

Fixes: https://tracker.ceph.com/issues/74848
Signed-off-by: Nitzan Mordechai <[email protected]>
NitzanMordhai pushed a commit to ceph/ceph-ci that referenced this pull request Feb 20, 2026
as the modules are now being loaded onto the main interpreter (see
ceph/ceph#66244), the
cherrypy is getting hit with an issue where its global state is being
affecting all the modules updating the cherrypy config simultaneously in
the same tree.

So i am adding a CherryPyMgr which manages all the independent servers
that will be created across all modules. This CherryPyMgr will create
its own server instances by utilizing cherrypy's WSGI Server and
eliminates the global state sharing. Each module or app can create their
own tree and start an adapter which will open an independent server for
that app.

- also added a method to update the config in place so CORS urls can be
  configured without restarting servers.

Fixes: https://tracker.ceph.com/issues/74643, https://tracker.ceph.com/issues/74543
Signed-off-by: Nizamudeen A <[email protected]>
NitzanMordhai pushed a commit to ceph/ceph-ci that referenced this pull request Feb 21, 2026
as the modules are now being loaded onto the main interpreter (see
ceph/ceph#66244), the
cherrypy is getting hit with an issue where its global state is being
affecting all the modules updating the cherrypy config simultaneously in
the same tree.

So i am adding a CherryPyMgr which manages all the independent servers
that will be created across all modules. This CherryPyMgr will create
its own server instances by utilizing cherrypy's WSGI Server and
eliminates the global state sharing. Each module or app can create their
own tree and start an adapter which will open an independent server for
that app.

- also added a method to update the config in place so CORS urls can be
  configured without restarting servers.

Fixes: https://tracker.ceph.com/issues/74643, https://tracker.ceph.com/issues/74543
Signed-off-by: Nizamudeen A <[email protected]>
NitzanMordhai pushed a commit to ceph/ceph-ci that referenced this pull request Feb 22, 2026
as the modules are now being loaded onto the main interpreter (see
ceph/ceph#66244), the
cherrypy is getting hit with an issue where its global state is being
affecting all the modules updating the cherrypy config simultaneously in
the same tree.

So i am adding a CherryPyMgr which manages all the independent servers
that will be created across all modules. This CherryPyMgr will create
its own server instances by utilizing cherrypy's WSGI Server and
eliminates the global state sharing. Each module or app can create their
own tree and start an adapter which will open an independent server for
that app.

- also added a method to update the config in place so CORS urls can be
  configured without restarting servers.

Fixes: https://tracker.ceph.com/issues/74643, https://tracker.ceph.com/issues/74543
Signed-off-by: Nizamudeen A <[email protected]>
NitzanMordhai pushed a commit to ceph/ceph-ci that referenced this pull request Feb 22, 2026
as the modules are now being loaded onto the main interpreter (see
ceph/ceph#66244), the
cherrypy is getting hit with an issue where its global state is being
affecting all the modules updating the cherrypy config simultaneously in
the same tree.

So i am adding a CherryPyMgr which manages all the independent servers
that will be created across all modules. This CherryPyMgr will create
its own server instances by utilizing cherrypy's WSGI Server and
eliminates the global state sharing. Each module or app can create their
own tree and start an adapter which will open an independent server for
that app.

- also added a method to update the config in place so CORS urls can be
  configured without restarting servers.

Fixes: https://tracker.ceph.com/issues/74643, https://tracker.ceph.com/issues/74543
Signed-off-by: Nizamudeen A <[email protected]>
NitzanMordhai pushed a commit to ceph/ceph-ci that referenced this pull request Feb 23, 2026
as the modules are now being loaded onto the main interpreter (see
ceph/ceph#66244), the
cherrypy is getting hit with an issue where its global state is being
affecting all the modules updating the cherrypy config simultaneously in
the same tree.

So i am adding a CherryPyMgr which manages all the independent servers
that will be created across all modules. This CherryPyMgr will create
its own server instances by utilizing cherrypy's WSGI Server and
eliminates the global state sharing. Each module or app can create their
own tree and start an adapter which will open an independent server for
that app.

- also added a method to update the config in place so CORS urls can be
  configured without restarting servers.

Fixes: https://tracker.ceph.com/issues/74643, https://tracker.ceph.com/issues/74543
Signed-off-by: Nizamudeen A <[email protected]>
(cherry picked from commit c0f77e4)

 Conflicts:
	src/pybind/mgr/cephadm/agent.py
 - removed the log filters and kept the ssl changes as it is
	src/pybind/mgr/dashboard/module.py
 - only added the new CherryPyMgr import
	src/pybind/mgr/prometheus/module.py
 - accepted the incoming changes
nizamial09 added a commit to rhcs-dashboard/ceph that referenced this pull request Feb 24, 2026
as the modules are now being loaded onto the main interpreter (see
ceph#66244), the
cherrypy is getting hit with an issue where its global state is being
affecting all the modules updating the cherrypy config simultaneously in
the same tree.

So i am adding a CherryPyMgr which manages all the independent servers
that will be created across all modules. This CherryPyMgr will create
its own server instances by utilizing cherrypy's WSGI Server and
eliminates the global state sharing. Each module or app can create their
own tree and start an adapter which will open an independent server for
that app.

- also added a method to update the config in place so CORS urls can be
  configured without restarting servers.

Fixes: https://tracker.ceph.com/issues/74643, https://tracker.ceph.com/issues/74543, https://tracker.ceph.com/issues/74980
Signed-off-by: Nizamudeen A <[email protected]>
@batrick

batrick commented Mar 6, 2026

Copy link
Copy Markdown
Member

@github-actions

Copy link
Copy Markdown
        This is an automated message by src/script/redmine-upkeep.py.

        I found one or more `Fixes:` tags in the commit messages in

        `git log bc733405b078f288389dbe6f44c3b4beb087c176^..bc733405b078f288389dbe6f44c3b4beb087c176`

        The referenced tickets are:

        * https://tracker.ceph.com/issues/73857

@tchaikov

Copy link
Copy Markdown
Contributor

@bazaah bazaah mentioned this pull request Jun 16, 2026
3 of 4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants