pybind/mgr: Hack around the 'ImportError: PyO3 modules may only be in… #61737
pybind/mgr: Hack around the 'ImportError: PyO3 modules may only be in… #61737
Conversation
37da554 to
d5ecc78
Compare
phlogistonjohn
left a comment
There was a problem hiding this comment.
This looks like a good start.
However, I strongly suggest taking the crypto code out of this file entirely and put it new .py file(s). Possibly in src/python-common somewhere and then instead of using python3 -c use python -m with if __name__ == '__main__ type guards in those files.
In the future we could then switch back to importing those new modules if/when the pyO3/rust/subintepreter issues are resolved with an even cleaner architecture overall.
Does this suggestion make sense to you?
|
It makes total sense however ... When I had a go at trying to implement it I bumped into a side effect I had not seen before. I've pushed the first stab for comparison and I provide a few examples of how to trigger things. Run newly converted module and validate errors: pyOpenSSL versions So, the options I think we have are:
I'm leaning towards option 3. |
|
I'm ok with your suggestions. FWIW we should be able to suppress warning when needed https://docs.python.org/3/library/warnings.html#temporarily-suppressing-warnings |
|
🤦♂️ I never pushed the first stab ... I reworked everything following your initial suggestion and applied the warnings, it turned out only the first block of code had the need for it. |
0c12faa to
f780aa1
Compare
|
WOOM. |
|
jenkins test api |
|
jenkins test make check |
|
jenkins test dashboard cephadm |
1 similar comment
|
jenkins test dashboard cephadm |
|
@nizamial09 @epuertat Given you both did some work in this area maybe you can advise forward or to /dev/null. |
|
@pecastro @phlogistonjohn related to the crypto functions (such as Which doesn't make sense to me as cephadm now is the responsible for generating self-signed certificates for the any mgr module who needs that (cephadm provides |
I'm fine with those suggestions but I also think we need to take things one step at a time. On top of that, |
|
What @phlogistonjohn said.
But mostly this:
This MR offers a potential solution for what is an existing problem and it does so in a way that is modular and feasible of rework in the future. |
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
batrick
left a comment
There was a problem hiding this comment.
Please squash Apply MR suggestions.
|
Hi all. I'm slowly catching up on some of the nice work @phlogistonjohn did which handles mostly all the of the previous cases you @epuertat had spotted as in need of improvement. I've just fixed a small typo and pushed and I suspect most of the remaining failures are due to the expectation of bytes vs string across the remote.py plumbing. The extra shim "has a different opinion" about the type of data returned that might have deeper implications. I like the standardization of returning strings for strings sake but some of the caller functions/methods might not agree with it. I'm running tests locally to see if I understand the full implications of this as well as the bytes vs strings mismatches. |
|
@phlogistonjohn I was thinking on either:
So my vote would be for the centralized config option. |
|
OK, that might be tricky wrt to the dependency flow, but I'll look into it. Right now we're just testing the basic workflow and yesterday we found another use of bcrypt module in the dashboard that was not being handled by the external process. I'm waiting to hear back on the status of that test run to see if we have more imports that need to be cleaned up. If all goes well, I'll continue organizing/refactoring. |
|
A brief update: @adk3798 ran the combined patch series (plus a fixup commit) through teuthology and it failed again. After almost a whole day's investigation we determined that the kubernetes module, used by k8sevents and rook mgr modules, imports cryptography and if either of these were imported before cephadm the boostrap would fail. We've summarized some proposed solutions here: https://pad.ceph.com/p/pyo3-cryptography-imports-k8s |
|
@epuertat When I said the cryptotools needed to die I was talking from a general perspective as in with hope that the issue would be solved by the pyo3 subintepreters folks. I understand the logic behind keeping the original code but have we considered the cons of this "suggestion"? I've added and a few more commits, some of which might be a bit controversial, like the last one removing ascii and utf-8 references across encode/decode. The tests seem to pass without those being explicitly stated. |
i had a tracker months ago to deprecate it since no one is actively maintaing it: https://tracker.ceph.com/issues/66091 |
|
Hi all, I have updated my branch with additional fixes and rebased on main. Unfortunately, one of the things I feared is starting to happen - @pecastro and I are fixing the same set of issues but in different ways. For example - I updated a test to stop encoding a string to bytes while @pecastro changed the code to accept either strings or bytes. Obviously, I prefer my approach and I think I can justify it but we're doing redundant work and creating extra work to reconcile the changes. To make my changes more visible I am going to create a seperate (draft) PR. My plan is to use it to partially rework the interface to generalize it and allow for either "subprocess mode" or "internal mode" - as discussed with @epuertat earlier in this PR. We will have to come up with a plan to reconcile our changes at some point though. |
|
My branch, in PR form: #62951 |
@phlogistonjohn curiously my first fix was the same as yours 😄 , in the meantime before pushing, I added the encoding to honour the test thinking , who knows, maybe there's a legitimate case somewhere where a bytes pkey is passed in. Given you're also in flow I can pause / stand down to minimize noise / attrition leaving the remaining bit of changing that In case you feel we should talk, I exist on a GMT schedule, but most of the work I do here is on GMT evenings. |
|
jenkins test api |
:-) Agreed. The reason I prefer to change the test and not the library code is that mypy is run (only) on the modules dir and passes indicating that there is a very good chance no other production code is passing in a bytes array. Since tests exist to verify the behavior of the production code and
I appreciate your offer, but I don't think I need that (yet). I just won't be rebasing on your branch frequently for the next couple of work days - not until all the fetures @epuertat and I discussed are implemented. I end up spending too much time in rebase, resolving conflicts rather than updating the code. I think it's fine if you continue to test and prove out that your patches work for your use cases. I'm working on making the code more modular and then making it configurable. In the meantime @adk3798 is helping test things in teuthology - main to prove the concept works as well as find other things we had previously overlooked, like the rook/k8sevents issue. Perhaps late next week I will revisit what you have done in the meantime and reconcile the branches.
Thank you for the offer. I don't think I need that (yet). More generally, if you are interested there's a Orch Weekly every Tuesday where we discuss design and various related topics and you are certainly welcome to join one of those too. |
…itialized once per interpreter process' issue. Fixes: https://tracker.ceph.com/issues/64213 Signed-off-by: Paulo E. Castro <[email protected]>
Where possible try to use structured output in JSON for easier parsing and interaction with the parent process. Signed-off-by: John Mulligan <[email protected]>
Create a class to act as a common shim between the cryptotools external functions and the mgr. It provides common conversion mechanisms and could possibly act as an abstraction in case we decide to make the external function calls in different ways in the future. Signed-off-by: John Mulligan <[email protected]>
Signed-off-by: John Mulligan <[email protected]>
Signed-off-by: John Mulligan <[email protected]>
Signed-off-by: John Mulligan <[email protected]>
Signed-off-by: Paulo E. Castro <[email protected]>
Signed-off-by: Paulo E. Castro <[email protected]>
…he exit. Signed-off-by: Paulo E. Castro <[email protected]>
Signed-off-by: Paulo E. Castro <[email protected]>
…ode/decode. Signed-off-by: Paulo E. Castro <[email protected]>
0bc8485 to
dbc0d64
Compare
Signed-off-by: Paulo E. Castro <[email protected]>
dbc0d64 to
7016a39
Compare
I'm done, obviously pending a re-review. The tests are passing and other than the dual mode running feature which @phlogistonjohn seems to be working on I've proven that this workaround is feasible to implement which was my primary goal with this MR alongside the perceived urgency of this fix. I've added the function name renaming that @epuertat suggested, and amended the commit messages to the standard but everything should still pretty much be as when @phlogistonjohn last rebased. |

…itialized once per interpreter process' issue.
Not sure if this ( using /usr/bin/python3 ) is fair use given we can't really seem to be able to get the interpreter being used with 'sys.executable' under CPython.
Fixes: https://tracker.ceph.com/issues/64213
This is an alternative approach to the attempt #57926 at solving the problem.
User hashes don't change, and all the mgr_utils.py use cases have been dealt with.
It's not pretty, but it works.
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 retest this pleasejenkins test classic perfjenkins test crimson perfjenkins test signedjenkins test make checkjenkins test make check arm64jenkins test submodulesjenkins test dashboardjenkins test dashboard cephadmjenkins test apijenkins test docsjenkins render docsjenkins test ceph-volume alljenkins test ceph-volume toxjenkins test windowsjenkins test rook e2e