Project

General

Profile

Actions

Bug #63529

closed
MC

Python Sub-Interpreter Model Used by ceph-mgr Incompatible With Python Modules Based on PyO3

Bug #63529: Python Sub-Interpreter Model Used by ceph-mgr Incompatible With Python Modules Based on PyO3

Added by Max Carrara about 3 years ago. Updated over 1 year ago.

Status:
Duplicate
Priority:
Normal
Assignee:
-
Category:
ceph-mgr
Target version:
-
Due date:
% Done:

100%

Source:
Community (dev)
Backport:
reef
Regression:
No
Severity:
2 - major
Reviewed:
Affected Versions:
ceph-qa-suite:
Pull request ID:
Tags (freeform):
Merge Commit:
Fixed In:
Released In:
Upkeep Timestamp:

Description

Our users noticed that Ceph's dashboard is broken in Proxmox Virtual Environment 8. On a more closer investigation, this is apparently caused by an import check in Python modules that use PyO3:

Sep 04 18:39:51 ceph-01 ceph-mgr[15669]: 2023-09-04T18:39:51.438+0200 7fecdc91e000 -1 mgr[py] Traceback (most recent call last):
Sep 04 18:39:51 ceph-01 ceph-mgr[15669]:   File "/usr/share/ceph/mgr/dashboard/__init__.py", line 60, in <module>
Sep 04 18:39:51 ceph-01 ceph-mgr[15669]:     from .module import Module, StandbyModule  # noqa: F401
Sep 04 18:39:51 ceph-01 ceph-mgr[15669]:     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sep 04 18:39:51 ceph-01 ceph-mgr[15669]:   File "/usr/share/ceph/mgr/dashboard/module.py", line 30, in <module>
Sep 04 18:39:51 ceph-01 ceph-mgr[15669]:     from .controllers import Router, json_error_page
Sep 04 18:39:51 ceph-01 ceph-mgr[15669]:   File "/usr/share/ceph/mgr/dashboard/controllers/__init__.py", line 1, in <module>
Sep 04 18:39:51 ceph-01 ceph-mgr[15669]:     from ._api_router import APIRouter
Sep 04 18:39:51 ceph-01 ceph-mgr[15669]:   File "/usr/share/ceph/mgr/dashboard/controllers/_api_router.py", line 1, in <module>
Sep 04 18:39:51 ceph-01 ceph-mgr[15669]:     from ._router import Router
Sep 04 18:39:51 ceph-01 ceph-mgr[15669]:   File "/usr/share/ceph/mgr/dashboard/controllers/_router.py", line 7, in <module>
Sep 04 18:39:51 ceph-01 ceph-mgr[15669]:     from ._base_controller import BaseController
Sep 04 18:39:51 ceph-01 ceph-mgr[15669]:   File "/usr/share/ceph/mgr/dashboard/controllers/_base_controller.py", line 11, in <module>
Sep 04 18:39:51 ceph-01 ceph-mgr[15669]:     from ..services.auth import AuthManager, JwtManager
Sep 04 18:39:51 ceph-01 ceph-mgr[15669]:   File "/usr/share/ceph/mgr/dashboard/services/auth.py", line 12, in <module>
Sep 04 18:39:51 ceph-01 ceph-mgr[15669]:     import jwt
Sep 04 18:39:51 ceph-01 ceph-mgr[15669]:   File "/lib/python3/dist-packages/jwt/__init__.py", line 1, in <module>
Sep 04 18:39:51 ceph-01 ceph-mgr[15669]:     from .api_jwk import PyJWK, PyJWKSet
Sep 04 18:39:51 ceph-01 ceph-mgr[15669]:   File "/lib/python3/dist-packages/jwt/api_jwk.py", line 6, in <module>
Sep 04 18:39:51 ceph-01 ceph-mgr[15669]:     from .algorithms import get_default_algorithms
Sep 04 18:39:51 ceph-01 ceph-mgr[15669]:   File "/lib/python3/dist-packages/jwt/algorithms.py", line 6, in <module>
Sep 04 18:39:51 ceph-01 ceph-mgr[15669]:     from .utils import (
Sep 04 18:39:51 ceph-01 ceph-mgr[15669]:   File "/lib/python3/dist-packages/jwt/utils.py", line 7, in <module>
Sep 04 18:39:51 ceph-01 ceph-mgr[15669]:     from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurve
Sep 04 18:39:51 ceph-01 ceph-mgr[15669]:   File "/lib/python3/dist-packages/cryptography/hazmat/primitives/asymmetric/ec.py", line 11, in <module>
Sep 04 18:39:51 ceph-01 ceph-mgr[15669]:     from cryptography.hazmat._oid import ObjectIdentifier
Sep 04 18:39:51 ceph-01 ceph-mgr[15669]:   File "/lib/python3/dist-packages/cryptography/hazmat/_oid.py", line 7, in <module>
Sep 04 18:39:51 ceph-01 ceph-mgr[15669]:     from cryptography.hazmat.bindings._rust import (
Sep 04 18:39:51 ceph-01 ceph-mgr[15669]: ImportError: PyO3 modules may only be initialized once per interpreter process
Sep 04 18:39:51 ceph-01 ceph-mgr[15669]: 2023-09-04T18:39:51.438+0200 7fecdc91e000 -1 mgr[py] Class not found in module 'dashboard'
Sep 04 18:39:51 ceph-01 ceph-mgr[15669]: 2023-09-04T18:39:51.438+0200 7fecdc91e000 -1 mgr[py] Error loading module 'dashboard': (2) No such file or directory
Sep 04 18:39:51 ceph-01 ceph-mgr[15669]: 2023-09-04T18:39:51.470+0200 7fecdc91e000 -1 mgr[py] Module progress has missing NOTIFY_TYPES member
Sep 04 18:39:51 ceph-01 ceph-mgr[15669]: 2023-09-04T18:39:51.502+0200 7fecdc91e000 -1 mgr[py] Module iostat has missing NOTIFY_TYPES member
Sep 04 18:39:51 ceph-01 ceph-mgr[15669]: 2023-09-04T18:39:51.502+0200 7fecdc91e000 -1 log_channel(cluster) log [ERR] : Failed to load ceph-mgr modules: dashboard
This error doesn't just appear in PVE, but also in:

This is due to the fact that every ceph-mgr module that uses Python modules that use PyO3 to provide bindings to Rust code will raise an ImportError if imported more than once under the presence of multiple Python sub-interpreters. This check is present in PyO3 version 0.17.0 and upwards and was introduced in this pull request: https://github.com/PyO3/pyo3/pull/2523

So, for now it seems that this "only" completely breaks the dashboard; however, other ceph-mgr modules might also be affected in the future, depending on whether they use PyO3 Python modules or not.

This also means that the official distribution of Ceph will be affected sooner or later, either when a newer version of Python's cryptography or PyO3 is used.

The above is essentially a summary of my findings and posts over at the Proxmox forum. For the curious, you can read up on everything starting from this post over here: https://forum.proxmox.com/threads/ceph-warning-post-upgrade-to-v8.129371/post-587100


Related issues 2 (0 open — 2 closed)

Is duplicate of Ceph - Bug #64213: MGR modules incompatible with later PyO3 versions - PyO3 modules may only be initialized once per interpreter processResolvedErnesto Puerta

Actions
Copied to mgr - Backport #66218: reef: Python Sub-Interpreter Model Used by ceph-mgr Incompatible With Python Modules Based on PyO3Resolved

Actions

IJ Updated by Iggy Jackson almost 3 years ago Actions #1

`bcrypt` is now also doing this, so I think basically every module is broken at this point.

MV Updated by Matthew Vernon almost 3 years ago Actions #3

Since that PR is a partial fix for this, I've put in https://github.com/ceph/ceph/pull/55689 to backport it to reef.

HM Updated by Hector Martin over 2 years ago Actions #4

bcrypt bug: https://github.com/pyca/bcrypt/issues/694

It looks like there is no fix in right, so I think the only solution is for Ceph to stop using the bcrypt module (or start vendoring an unaffected 3.x version somehow).

Note that this is currently breaking Ceph in at least Gentoo and Fedora 40, and presumably every rolling distro and recent releases of many other non-rolling distros by now.

KS Updated by Konstantin Shalygin over 2 years ago Actions #5

  • Status changed from New to Pending Backport
  • Backport set to reef
  • Pull request ID set to 63529

UB Updated by Upkeep Bot over 2 years ago Actions #6

  • Copied to Backport #66218: reef: Python Sub-Interpreter Model Used by ceph-mgr Incompatible With Python Modules Based on PyO3 added

MC Updated by Max Carrara over 2 years ago Actions #8

For reference, I'm currently working on sub-interpreter support for PyO3.

I have no clear idea when it will be finished, but there's been a bit of progress recently, finally.

For anyone that's stumbling over this issue here and wants to see what's going on, the tracking issue at PyO3's is over here: https://github.com/PyO3/pyo3/issues/3451

If you want to help out, let me know over at: https://github.com/Aequitosh/pyo3/discussions/1

Implementing this still has a long way to go, and it will probably take even longer until it trickles downstream to Python packages like bcrypt & cryptography; nevertheless, it's going somewhere.

KS Updated by Konstantin Shalygin over 2 years ago Actions #9

  • Status changed from Pending Backport to Resolved
  • % Done changed from 0 to 100

HM Updated by Hector Martin over 2 years ago Actions #10

Why was this closed? This is not fixed. The dependency on cryptography was removed, but the dependency on bcrypt remains, and that is still breaking everything.

Please reopen. This won't be fixed until Ceph either stops depending on external bcrypt or bcrypt/pyo3 starts working with subinterpreters.

NA Updated by Nizamudeen A over 2 years ago Actions #11

  • Related to Bug #64213: MGR modules incompatible with later PyO3 versions - PyO3 modules may only be initialized once per interpreter process added

NA Updated by Nizamudeen A over 2 years ago Actions #12

Hector,

The core issue is tracked via a different tracker which I linked here.

IJ Updated by Iggy Jackson over 2 years ago Actions #13

Seems weird to make the newer bug with less info the main bug for this issue, but maybe I just didn't understand how redmine works.

EP Updated by Ernesto Puerta over 1 year ago Actions #14

  • Status changed from Resolved to Duplicate
  • Pull request ID deleted (63529)

EP Updated by Ernesto Puerta over 1 year ago Actions #15

  • Related to deleted (Bug #64213: MGR modules incompatible with later PyO3 versions - PyO3 modules may only be initialized once per interpreter process)

EP Updated by Ernesto Puerta over 1 year ago Actions #16

  • Is duplicate of Bug #64213: MGR modules incompatible with later PyO3 versions - PyO3 modules may only be initialized once per interpreter process added
Actions

Also available in: PDF Atom