pybind/mgr: Protobuffer file generation for grpc deps.#61089
pybind/mgr: Protobuffer file generation for grpc deps.#61089nizamial09 merged 3 commits intoceph:mainfrom
Conversation
|
That's great @pecastro ! The challenge with the proto-generated Python files is the The fix involved invoking the script from a specific path location with some "../.." stuff around to force it use the correct relative paths... Sorry for my vague description. I managed to make it work time ago, but I don't remember the exact command 😓 @nizamial09 maybe you're luckier here? |
fc29622 to
09b01f1
Compare
09b01f1 to
ce834b5
Compare
|
Can one of the admins verify this patch? |
3c778d1 to
5bb4120
Compare
5bb4120 to
ddfd508
Compare
|
@epuertat @nizamial09 It built and it passed make check. 🎉 |
@epuertat I don't fully remember it and I can't track the command logs in history since I had to use container to make it work (my system python version was not the one used to build ceph on centos9). And thanks @pecastro for the PR. I will run this through our build pipeline to test and generate an image to see whether the protobuf files are actually there and nothing's went wrong in the build. Sorry for making you wait here. |
Looks like @pecastro nailed it! Yeah, it had to do with the relative path you fed the protoc generation command. |
5f97a2a to
2125187
Compare
|
a new shaman build triggered ⌛ |
|
Humm ... I think I've "streamlined" it a bit too much. The import paths of the generated files are not the same as before therefore preventing the correct import of the model. |
2125187 to
d4985f5
Compare
| # protobuffer files generation | ||
| add_custom_command( | ||
| OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/services/proto/gateway_pb2.py" "${CMAKE_CURRENT_SOURCE_DIR}/services/proto/gateway_pb2_grpc.py" | ||
| COMMAND cp ${CEPH_NVME_GATEWAY_PROTO_DIR}/gateway.proto dashboard/services/proto/gateway.proto |
There was a problem hiding this comment.
@pecastro, thank you for exploring the streamlining suggestion! It seems relative paths can be a bit tricky for protoc, as highlighted by this error: 😀
protoc is too dumb to figure out when two paths (e.g., absolute and relative) are equivalent (it's harder than you think)
Perhaps we could address this by substituting the copying of the protobuf file during build time with creating a symbolic link as part of this PR as git handles symbolic links quite well. I tested this approach in the src/pybind/mgr/dashboard/services/proto directory:
$ ln -s ../../../../../../src/nvmeof/gateway/control/proto/gateway.proto .
$ ls -l gateway.proto
lrwxrwxrwx. 1 baum baum 64 Jan 17 06:01 gateway.proto -> ../../../../../../src/nvmeof/gateway/control/proto/gateway.proto
$ python -m grpc_tools.protoc --proto_path=. --python_out=. --grpc_python_out=. gateway.proto
Alternatively, passing a relative --proto_path seems to work in the src/pybind/mgr/dashboard/services/proto directory, eliminating the need for a protobuf file copy or symbolic link. Does it cause any issues with imports?
$ rm gateway.proto
$ python -m grpc_tools.protoc --proto_path=../../../../../../src/nvmeof/gateway/control/proto/ --python_out=. --grpc_python_out=. gateway.protoLet me know what you think!
There was a problem hiding this comment.
I remember I managed to make it work just by invoking the script from a specific location that led it to match the expected import path... I'll look for that line again.
There was a problem hiding this comment.
Since you're setting the WORKING_DIRECTORYin the add_custom_command(), you should be able to use relative paths there. It should be something like (maybe adding the dashboard subdir too):
python -m grpc_tools.protoc -I./services/proto \
--python_out=. --grpc_python_out=. \
services/proto/gateway.protoThere was a problem hiding this comment.
@pecastro, thank you for exploring the streamlining suggestion! It seems relative paths can be a bit tricky for protoc, as highlighted by this error: 😀
@baum Where did that error come from exactly ?
I've seen it during development of the fix whilst I was trying different invocations of the final result but not since I committed and pushed.
The pipeline failed make check but on a test unrelated to this work.
The relevant test is run-tox-mgr-dashboard-openapi which passed with success if you check the console output.
make check (arm 64) also passed in the github pipeline. :)
There was a problem hiding this comment.
test failures looked unrelated so retriggered it.
|
jenkins retest this please |
|
jenkins test make check |
It can't log differently, the only difference I saw in your shaman logs would be the percentual completion on the CMake output vs saying [ 10/2231 ]. Can you check if the files inside services/proto are the newly generated ones vs being the old ones? The MR removes the old files but the added CMake code will create them in the same place. |
|
@pecastro you are right. the files inside the container was older ones. So I've been trying to understand the build pipeline. So far and from what I gathered, apart from just generating the protobuf files during the build pipelines, we also need to install those generated protobuf files inside the ceph container so that those files will be there in the designated folder. We already do this for some things like the grafana: https://github.com/ceph/ceph/blob/main/ceph.spec.in#L1660 But the thing that I can't figure out is the proto file generation itself and where does that happen in the build pipeline. I don't see any traces of dashboard CMakelist getting executed there. Rather the dashboard is fed as an rpm after the cmake step. So I am not entirely sure how the CMakelist works here and I'll need help from @epuertat to figure that part out. |
|
If And this line https://github.com/ceph/ceph/blob/main/ceph.spec.in#L1466C7-L1466C34 is suspicious. Using this branch though, means the old files will be removed. If you are saying that the files inside the container are the old one, that means the container was generated off a different revision and not from this branch nor with these commits cherry-picked. It would be great to understand the build process better. Is the shaman build script public ?! I could always try to move the code that builds the proto files out of the |
|
@pecastro : |
Fixes: https://tracker.ceph.com/issues/64681 Signed-off-by: Paulo E. Castro <pecastro@wormholenet.com>
…oto using the protobuf file from the gateway submodule. - Remove old gateway-proto. - Updated src/nvmeof/gateway to the latest sha-1 from devel. Signed-off-by: Paulo E. Castro <pecastro@wormholenet.com>
- This ensures protos are built during the RPM build process. - gitignore the sourced gateway.proto file. Signed-off-by: Paulo E. Castro <pecastro@wormholenet.com>
d4985f5 to
37e6333
Compare
|
I moved the build proto logic out of the @nizamial09 If you trigger a shaman build you'll be able to validate the new proto files with something like: VS old file |
|
Thank you @pecastro. I am trying to schedule a shaman run but it looks like a long queue there. will see if it ever turns up there |
|
jenkins test make check arm64 |
|
yup, now i am seeing the correct proto files in the image as well. thank you so much for taking care of it. @pecastro |
|
this could be ready to merge once the test passes then. |
It disables the specific pinning to a Python xmlsec version. Fixes: https://tracker.ceph.com/issues/70019 Fixes: 37e6333 Fixes: ceph#61089 Signed-off-by: Ernesto Puerta <epuertat@redhat.com>
| add_custom_command( | ||
| OUTPUT ${CEPH_GRPC_VIRTUALENV}/lib/python*/site-packages/grpc_tools | ||
| COMMAND ${CMAKE_SOURCE_DIR}/src/tools/setup-virtualenv.sh --python=${Python3_EXECUTABLE} ${CEPH_GRPC_VIRTUALENV} | ||
| COMMAND ${CEPH_GRPC_VIRTUALENV}/bin/pip install grpcio-tools |
There was a problem hiding this comment.
We shouldn't have this here. All Python deps should be installed from requirements.txt files.
There was a problem hiding this comment.
BTW, IMHO the proto files should be generated with each distro's grpc-tools packages. That's the only way to ensure the generated code is compatible with each distro's version.
There was a problem hiding this comment.
FWIW ... #61089 (comment)
I can have a look into redoing some of this in that direction.
There was a problem hiding this comment.
At least in RPM-based systems (DEB-based systems have a similar mechanism), build-specific deps should be installed through BuildRequires: in the ceph.spec.in file.
It disables the specific pinning to a Python xmlsec version. Fixes: https://tracker.ceph.com/issues/70019 Fixes: 37e6333 Fixes: ceph/ceph#61089 Signed-off-by: Ernesto Puerta <epuertat@redhat.com>
|
@epuertat @nizamial09 This was what the MR added https://github.com/ceph/ceph/blame/main/src/pybind/mgr/dashboard/CMakeLists.txt The Also, moving the proto generation to inside the tox tests is not going to work because if the proto files are not generated as part of the build they'll never make it to the rpm. Before being generated as of now, they were part of the repository.
I agree with the first part of the sentence and looking at some of the later comments @epuertat left on the original PR
I found this a bit problematic. I kept on bumping into an error generating the protos when using older versions of the grpc python module (ubuntu22.04) which was in a way invalidating the premise of using the distro package to generate the code. So, under catch 22 I decided to fix forward. |
Yes, that's because the
We probably abused of tox for non-test tasks (OpenAPI spec generation, etc) but it's a good framework to quickly run Python reproducible environments without having to worry about deps, etc. Keep in mind that (unfortunately) Ceph CI is not yet virtualized/containerized.
The
The question is that proto stuff is generated during the package creation, so it will always run along with the same grpc package versions. |
It disables the specific pinning to a Python xmlsec version. Fixes: https://tracker.ceph.com/issues/70019 Fixes: 37e6333 Fixes: ceph#61089 Signed-off-by: Ernesto Puerta <epuertat@redhat.com>
It disables the specific pinning to a Python xmlsec version. Fixes: https://tracker.ceph.com/issues/70019 Fixes: 37e6333 Fixes: ceph#61089 Signed-off-by: Ernesto Puerta <epuertat@redhat.com>
It disables the specific pinning to a Python xmlsec version. Fixes: https://tracker.ceph.com/issues/70019 Fixes: 37e6333 Fixes: ceph#61089 Signed-off-by: Ernesto Puerta <epuertat@redhat.com>
| add_custom_target(mgr-dashboard-services-build | ||
| ALL | ||
| DEPENDS mgr-dashboard-services-deps) | ||
|
|
||
| add_dependencies(tests mgr-dashboard-services-build) |
There was a problem hiding this comment.
@pecastro a slack user reports that this new dashboard stuff breaks the build when WITH_NVMEOF_GATEWAY_MONITOR_CLIENT=OFF
can you please add if(WITH_NVMEOF_GATEWAY_MONITOR_CLIENT) where necessary to fix this?
There was a problem hiding this comment.
@cbodley, @nizamial09 is in the process of reverting the commits from this PR here #62103. So that will stop being an issue once that is done.
I'll factor that WITH_NVMEOF_GATEWAY_MONITOR_CLIENT in the new PR #61967 that is being worked to make the GRPC components more streamlined and stable.
It disables the specific pinning to a Python xmlsec version. Fixes: https://tracker.ceph.com/issues/70019 Fixes: 37e6333 Fixes: ceph/ceph#61089 Signed-off-by: Ernesto Puerta <epuertat@redhat.com>


Fixes: https://tracker.ceph.com/issues/64681
@nizamial09, @epuertat Please have a look and share your thoughts.
This aligns with the suggestion here #60719 (comment)
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