From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 132C71FF183 for ; Wed, 16 Jul 2025 19:39:29 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id CB27F18A85; Wed, 16 Jul 2025 19:40:33 +0200 (CEST) From: "Max R. Carrara" To: pve-devel@lists.proxmox.com Date: Wed, 16 Jul 2025 19:39:56 +0200 Message-Id: <20250716173956.980112-3-m.carrara@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250716173956.980112-1-m.carrara@proxmox.com> References: <20250716173956.980112-1-m.carrara@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.082 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_MSPIKE_H2 0.001 Average reputation (+2) SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH v1 master ceph 2/2] mgr: fix errors regarding module imports and NOTIFY_TYPES attributes X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" By handling the AttributeError that is thrown internally, the import of several mgr modules also works again. See the patch's message for all details. Signed-off-by: Max R. Carrara --- ...mport-by-making-NOTIFY_TYPES-in-py-m.patch | 56 +++++++++++++++++++ patches/series | 1 + 2 files changed, 57 insertions(+) create mode 100644 patches/0059-mgr-fix-module-import-by-making-NOTIFY_TYPES-in-py-m.patch diff --git a/patches/0059-mgr-fix-module-import-by-making-NOTIFY_TYPES-in-py-m.patch b/patches/0059-mgr-fix-module-import-by-making-NOTIFY_TYPES-in-py-m.patch new file mode 100644 index 0000000000..5595c96c9e --- /dev/null +++ b/patches/0059-mgr-fix-module-import-by-making-NOTIFY_TYPES-in-py-m.patch @@ -0,0 +1,56 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: "Max R. Carrara" +Date: Wed, 16 Jul 2025 16:31:43 +0200 +Subject: [PATCH 59/59] mgr: fix module import by making NOTIFY_TYPES in py + modules optional + +If NOTIFY_TYPES isn't an attribute of the passed class, the Python +(sub-)interpreter raises an AttributeError that must be handled or cleared +explicitly via the Python C-API. Unfortunately, this isn't done here, +which means that the exception sticks around until handled. + +This caused a call to PyModule::load_subclass_of() to fail and +incorrectly report the AttributeError as cause. + +Checking whether the class has NOTIFY_TYPES as attribute in the first +place fixes this. + +Note that there's an upstream PR [0] that wasn't backported that aimed +to fix this, but does so incorrectly, as the exception is still not +cleared there. The warnings regarding NOTIFY_TYPES missing also occurs +on Reef but doesn't cause any module imports to fail there. As the +affected Ceph code has stayed mostly the same between bookworm and +trixie releases, this suggests that some behavior between Python 3.11 +and 3.13 likely changed. + +Either way, avoiding the AttributeError altogether fixes this. + +[0]: https://github.com/ceph/ceph/pull/57106 + +Signed-off-by: Max R. Carrara +--- + src/mgr/PyModule.cc | 10 ++++++---- + 1 file changed, 6 insertions(+), 4 deletions(-) + +diff --git a/src/mgr/PyModule.cc b/src/mgr/PyModule.cc +index 084cf3ffc1e..e6fd269dca5 100644 +--- a/src/mgr/PyModule.cc ++++ b/src/mgr/PyModule.cc +@@ -513,11 +513,13 @@ int PyModule::register_options(PyObject *cls) + + int PyModule::load_notify_types() + { +- PyObject *ls = PyObject_GetAttrString(pClass, "NOTIFY_TYPES"); +- if (ls == nullptr) { +- derr << "Module " << get_name() << " has missing NOTIFY_TYPES member" << dendl; +- return -EINVAL; ++ if (!PyObject_HasAttrString(pClass, "NOTIFY_TYPES")) { ++ dout(10) << "Module " << get_name() << " has no NOTIFY_TYPES member" << dendl; ++ return 0; + } ++ ++ PyObject *ls = PyObject_GetAttrString(pClass, "NOTIFY_TYPES"); ++ + if (!PyObject_TypeCheck(ls, &PyList_Type)) { + // Relatively easy mistake for human to make, e.g. defining COMMANDS + // as a {} instead of a [] diff --git a/patches/series b/patches/series index ff23f8b640..b820614566 100644 --- a/patches/series +++ b/patches/series @@ -52,3 +52,4 @@ 0056-mgr-cephadm-always-use-the-internal-cryptocaller.patch 0057-mgr-dashboard-add-an-option-to-control-the-dashboard.patch 0058-pybind-mgr-restful-provide-workaround-for-PyO3-Impor.patch +0059-mgr-fix-module-import-by-making-NOTIFY_TYPES-in-py-m.patch -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel