Repository navigation
mgr: set sys.executable in PyConfig for subprocess spawning - #69239
NitzanMordhai wants to merge 1 commit into
Conversation
The PyO3 workaround for cryptographic functions spawns a separate Python interpreter to avoid subinterpreter conflicts. Previously, it used hardcoded 'python3' from PATH, which breaks in environments like NixOS where Python is not in PATH or when multiple Python versions are installed. This commit fixes the issue in two parts: 1. PyModuleRegistry.cc: Set py_config.executable during Python initialization using PyConfig_SetBytesString. This ensures sys.executable is properly populated in the mgr Python environment. 2. cryptotools/remote.py: Use sys.executable as the primary source for the Python interpret path. Fixes: https://tracker.ceph.com/issues/75768 Signed-off-by: Nitzan Mordechai <[email protected]>
| _input = input_data.encode() | ||
| cmd = ['python3', '-m', _ctmodule] + list(args) | ||
| # Use sys.executable if available, otherwise fall back to python3 | ||
| python_exe = sys.executable or shutil.which('python3') or 'python3' |
There was a problem hiding this comment.
How can we test something like this? Or are we just bound to have to wing it? :-)
There was a problem hiding this comment.
@phlogistonjohn i missed that PR that is already fixing that #67904
it will be hard to automate tests like that. I tried to use PyEnv locally and test it - build with python3.9 use pyenv to switch local python to 3.11 and check the python_exe that is actually 3.9
There was a problem hiding this comment.
Yeah, that's what I was afraid of.
WRT #67904 - I much prefer the more targeted fixes in this current pr here.
There was a problem hiding this comment.
WRT #67904 - I much prefer the more targeted fixes in this current pr here.
As is mentioned in the PR over there, the first two commits from that PR can be easily cherry-picked.
| status = PyConfig_SetString(&py_config, &py_config.program_name, WCHAR(MGR_PYTHON_EXECUTABLE)); | ||
| ceph_assertf(!PyStatus_Exception(status), "PyConfig_SetString: %s:%s", status.func, status.err_msg); | ||
| ceph_assertf(!PyStatus_Exception(status), "PyConfig_SetString(program_name): %s:%s", status.func, status.err_msg); |
There was a problem hiding this comment.
Unless I'm mistaken, won't this still set py_config.program_name to the literal string MGR_PYTHON_EXECUTABLE1?
Footnotes
There was a problem hiding this comment.
That IS the case.
|
This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days. |
|
This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days. |
Ceph PR triage — related open PRsQueried #69239 against KB snapshot
This comment is updated in place when the workflow re-runs (hidden HTML marker). Data: read-only GitHub + local git analysis; no labels or merges were changed. |
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
The PyO3 workaround for cryptographic functions spawns a separate Python interpreter to avoid subinterpreter conflicts. Previously, it used hardcoded 'python3' from PATH, which breaks in environments like NixOS where Python is not in PATH or when multiple Python versions are installed.
This commit fixes the issue in two parts:
PyModuleRegistry.cc: Set py_config.executable during Python initialization using PyConfig_SetBytesString. This ensures sys.executable is properly populated in the mgr Python environment.
cryptotools/remote.py: Use sys.executable as the primary source for the Python interpret path.
Fixes: https://tracker.ceph.com/issues/75768
Contribution Guidelines
To sign and title your commits, please refer to Submitting Patches to Ceph.
If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.
When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
Show available Jenkins commands
jenkins test classic perfJenkins Job | Jenkins Job Definitionjenkins test crimson perfJenkins Job | Jenkins Job Definitionjenkins test signedJenkins Job | Jenkins Job Definitionjenkins test make checkJenkins Job | Jenkins Job Definitionjenkins test make check arm64Jenkins Job | Jenkins Job Definitionjenkins test submodulesJenkins Job | Jenkins Job Definitionjenkins test dashboardJenkins Job | Jenkins Job Definitionjenkins test dashboard cephadmJenkins Job | Jenkins Job Definitionjenkins test apiJenkins Job | Jenkins Job Definitionjenkins test docsReadTheDocs | Github Workflow Definitionjenkins test ceph-volume allJenkins Jobs | Jenkins Jobs Definitionjenkins test windowsJenkins Job | Jenkins Job Definitionjenkins test rook e2eJenkins Job | Jenkins Job DefinitionYou must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.