Compare commits
4 Commits
| Author | SHA256 | Date | |
|---|---|---|---|
| eae632f9b2 | |||
| f6c41ec8b9 | |||
| 23b7943698 | |||
| 770c9a87f4 |
@@ -1,33 +0,0 @@
|
||||
From 4589c4d8ac524206d4fb6349b07c5a4e83f926dc Mon Sep 17 00:00:00 2001
|
||||
From: John Mulligan <jmulligan@redhat.com>
|
||||
Date: Fri, 26 Apr 2024 10:53:33 -0400
|
||||
Subject: [PATCH] mgr: do not require NOTIFY_TYPES in python modules
|
||||
|
||||
Many python mgr modules lack a NOTIFY_TYPES member apparently without
|
||||
any downsides beyond an annoying message in the logs. This includes
|
||||
commonly used mgr modules like 'volumes' and 'cephadm'. Stop emitting
|
||||
an error for missing NOTIFY_TYPES by not assuming all mgr modules in
|
||||
python should provide it. The return code is also changed to indicate
|
||||
that this is not an error but the return from this function is never
|
||||
checked and so it should have no impact. However, if someone started
|
||||
using the return value in the future this would match the log change.
|
||||
|
||||
Fixes: https://tracker.ceph.com/issues/55835
|
||||
Signed-off-by: John Mulligan <jmulligan@redhat.com>
|
||||
---
|
||||
src/mgr/PyModule.cc | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
--- a/src/mgr/PyModule.cc
|
||||
+++ b/src/mgr/PyModule.cc
|
||||
@@ -437,8 +437,8 @@ 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;
|
||||
+ dout(10) << "Module " << get_name() << " has no NOTIFY_TYPES member" << dendl;
|
||||
+ return 0;
|
||||
}
|
||||
if (!PyObject_TypeCheck(ls, &PyList_Type)) {
|
||||
// Relatively easy mistake for human to make, e.g. defining COMMANDS
|
||||
@@ -0,0 +1,54 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: "Max R. Carrara" <m.carrara@proxmox.com>
|
||||
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 <m.carrara@proxmox.com>
|
||||
---
|
||||
src/mgr/PyModule.cc | 10 ++++++----
|
||||
1 file changed, 6 insertions(+), 4 deletions(-)
|
||||
|
||||
--- a/src/mgr/PyModule.cc
|
||||
+++ b/src/mgr/PyModule.cc
|
||||
@@ -435,11 +435,13 @@ int PyModule::register_options(PyObject
|
||||
|
||||
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 []
|
||||
11
ceph.changes
11
ceph.changes
@@ -1,3 +1,14 @@
|
||||
-------------------------------------------------------------------
|
||||
Tue Oct 7 08:40:26 UTC 2025 - James Oakley <jfunk@opensuse.org>
|
||||
|
||||
- Add cephadm-reproducible.patch for reproducible builds
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sat Aug 23 13:05:12 UTC 2025 - James Oakley <jfunk@opensuse.org>
|
||||
|
||||
- Replace ceph-mgr-do-not-require-NOTIFY_TYPES-in-python-modules.patch with
|
||||
more correct ceph-mgr-fix-module-import-by-making-NOTIFY_TYPES-in-py-m.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Jul 18 14:07:16 UTC 2025 - Lucas Mulling <lucas.mulling@suse.com>
|
||||
|
||||
|
||||
@@ -212,16 +212,18 @@ Patch7: ceph-pybind-fix-c-type-errors-in-cython-generated-python-binding
|
||||
Patch8: ceph-volume-fix-importlib.metadata-compat.patch
|
||||
# PATCH-FIX-UPSTREAM ceph-mgr-python-avoid-pyo3-errors.patch -- PR #62951
|
||||
Patch9: ceph-mgr-python-avoid-pyo3-errors.patch
|
||||
# PATCH-FIX-UPSTREAM ceph-mgr-do-not-require-NOTIFY_TYPES-in-python-modules.patch -- 4589c4d8ac524206d4fb6349b07c5a4e83f926dc
|
||||
Patch10: ceph-mgr-do-not-require-NOTIFY_TYPES-in-python-modules.patch
|
||||
# PATCH-FIX-UPSTREAM ceph-mgr-fix-module-import-by-making-NOTIFY_TYPES-in-py-m.patch
|
||||
Patch10: ceph-mgr-fix-module-import-by-making-NOTIFY_TYPES-in-py-m.patch
|
||||
# PATCH-FIX-OPENSUSE ceph-mgr-workaround-numpy-28271.patch -- Workaround for numpy #28271
|
||||
Patch11: ceph-mgr-workaround-numpy-28271.patch
|
||||
# PATCH-FIX-UPSTREAM ceph-mgr-do-not-require-NOTIFY_TYPES-in-python-modules.patch -- PR #63952
|
||||
# PATCH-FIX-UPSTREAM cephadm-fix-get_cluster_count_when_data_dir_is_missing.patch -- PR #63952
|
||||
Patch12: cephadm-fix-get_cluster_count_when_data_dir_is_missing.patch
|
||||
# PATCH-FIX-OPENSUSE ceph-rocksdb-gcc15.patch -- Fix gcc15 compatibility issues
|
||||
Patch13: ceph-rocksdb-gcc15.patch
|
||||
# PATCH-FIX-UPSTREAM replace CryptoPP calls with GnuTLS [jsc#PED-13011]
|
||||
Patch14: ceph-replace-CryptoPP-calls-with-GnuTLS.patch
|
||||
# PATCH-FIX-OPENSUSE cephadm-reproducible.patch -- Ensure cephadm executable is reproducible
|
||||
Patch15: cephadm-reproducible.patch
|
||||
%if 0%{?suse_version}
|
||||
# _insert_obs_source_lines_here
|
||||
ExclusiveArch: x86_64 aarch64 ppc64le s390x riscv64
|
||||
|
||||
87
cephadm-reproducible.patch
Normal file
87
cephadm-reproducible.patch
Normal file
@@ -0,0 +1,87 @@
|
||||
--- a/src/cephadm/build.py
|
||||
+++ b/src/cephadm/build.py
|
||||
@@ -12,7 +12,6 @@ import os
|
||||
import pathlib
|
||||
import shutil
|
||||
import subprocess
|
||||
-import tempfile
|
||||
import sys
|
||||
|
||||
HAS_ZIPAPP = False
|
||||
@@ -57,11 +56,12 @@ def _did_rexec():
|
||||
def _build(dest, src, versioning_vars=None):
|
||||
"""Build the binary."""
|
||||
os.chdir(src)
|
||||
- tempdir = pathlib.Path(tempfile.mkdtemp(suffix=".cephadm.build"))
|
||||
- log.debug("working in %s", tempdir)
|
||||
+ builddir = pathlib.Path(".cephadm.build")
|
||||
+ os.mkdir(builddir)
|
||||
+ log.debug("working in %s", builddir)
|
||||
try:
|
||||
if os.path.isfile("requirements.txt"):
|
||||
- _install_deps(tempdir)
|
||||
+ _install_deps(builddir)
|
||||
log.info("Copying contents")
|
||||
# TODO: currently the only file relevant to a compiled cephadm is the
|
||||
# cephadm.py file. Once cephadm is broken up into multiple py files
|
||||
@@ -69,19 +69,19 @@ def _build(dest, src, versioning_vars=No
|
||||
# sort organized structure to track what gets copied into the
|
||||
# dir to be zipped. For now we just have a simple call to copy
|
||||
# (and rename) the one file we care about.
|
||||
- shutil.copy("cephadm.py", tempdir / "__main__.py")
|
||||
+ shutil.copy("cephadm.py", builddir / "__main__.py")
|
||||
if versioning_vars:
|
||||
- generate_version_file(versioning_vars, tempdir / "_version.py")
|
||||
- _compile(dest, tempdir)
|
||||
+ generate_version_file(versioning_vars, builddir / "_version.py")
|
||||
+ _compile(dest, builddir)
|
||||
finally:
|
||||
- shutil.rmtree(tempdir)
|
||||
+ shutil.rmtree(builddir)
|
||||
|
||||
|
||||
-def _compile(dest, tempdir):
|
||||
+def _compile(dest, builddir):
|
||||
"""Compile the zipapp."""
|
||||
log.info("Byte-compiling py to pyc")
|
||||
compileall.compile_dir(
|
||||
- tempdir,
|
||||
+ builddir,
|
||||
maxlevels=16,
|
||||
legacy=True,
|
||||
quiet=1,
|
||||
@@ -91,7 +91,7 @@ def _compile(dest, tempdir):
|
||||
log.info("Constructing the zipapp file")
|
||||
try:
|
||||
zipapp.create_archive(
|
||||
- source=tempdir,
|
||||
+ source=builddir,
|
||||
target=dest,
|
||||
interpreter=sys.executable,
|
||||
compressed=True,
|
||||
@@ -100,14 +100,14 @@ def _compile(dest, tempdir):
|
||||
except TypeError:
|
||||
# automatically fall back to uncompressed
|
||||
zipapp.create_archive(
|
||||
- source=tempdir,
|
||||
+ source=builddir,
|
||||
target=dest,
|
||||
interpreter=sys.executable,
|
||||
)
|
||||
log.info("Zipapp created without compression")
|
||||
|
||||
|
||||
-def _install_deps(tempdir):
|
||||
+def _install_deps(builddir):
|
||||
"""Install dependencies with pip."""
|
||||
# TODO we could explicitly pass a python version here
|
||||
log.info("Installing dependencies")
|
||||
@@ -121,7 +121,7 @@ def _install_deps(tempdir):
|
||||
"--requirement",
|
||||
"requirements.txt",
|
||||
"--target",
|
||||
- tempdir,
|
||||
+ builddir,
|
||||
]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user