-
Notifications
You must be signed in to change notification settings - Fork 592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: magma deb build is bazelified #13749
Conversation
Thanks for opening a PR! 💯
Howto
More infoPlease take a moment to read through the Magma project's
If this is your first Magma PR, also consider reading
|
516e96a
to
a64156e
Compare
I just tried a build on my VM and I can't see the sctpd package described in the test plan.
|
woops, c&p issue ... corrected in test plan. |
"far less dependencies are needed because bazel builds as hermetic as possible" - I noticed that the list is a lot smaller than in the latest release from focal-ci. So the reason is that pydep adds many more dependencies than needed? |
Almost all python3-foo dependencies are not needed anymore. But iirc a make built magma.deb has all python3-foo dependencies twice (i.e., the list feels a lot longer). I do not know if pydep adds unnecessary dependencies. |
From looking at the built magma.deb, the main difference in file size is because of the C++ services (mme, sessiond...). Is this because Bazel compiles all dependencies into the file or is there something else going on? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still reviewing...
"../com_google_protobuf", | ||
# external grpc is only needed during compile time | ||
"../com_github_grpc_grpc", | ||
"_solib_k8/libexternal_Scom_Ugithub_Ugrpc_Ugrpc_Slibgrpc.so", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a comment here too (whatever that thing is :)).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will. The long description for the record: this is how bazel compiles dynamic libraries - separators like /
and .
are encoded -> libexternal/com.github.grpc.grpc/libgrpc.so
. But it's still a library that is only needed during compile time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed
"ebpf/byte_count.bpf.c", | ||
"ebpf/common.bpf.h", | ||
], | ||
data = ["//lte/gateway/python/magma/kernsnoopd/ebpf:ebpf_data_files"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These might be duplicated somehow. I see them both in
└── var
├── opt
│ └── magma
│ ├── ebpf
│ │ ├── ebpf_dl_handler.c
│ │ ├── ebpf_manager.py
│ │ ├── ebpf_ul_handler.c
│ │ └── kernsnoopd
│ │ ├── byte_count.bpf.c
│ │ └── common.bpf.h
│ └── envoy.yaml
and usr/local/lib/python3.8
│ │ │ ├── kernsnoopd
│ │ │ │ ├── ebpf
│ │ │ │ │ ├── byte_count.bpf.c
│ │ │ │ │ └── common.bpf.h
│ │ │ │ ├── handlers.py
│ │ │ │ ├── kernsnoopd
│ │ │ │ ├── main.py
│ │ │ │ ├── metrics.py
│ │ │ │ └── snooper.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice catch - seems like this is inconsistent to the make magma.deb file. I will have a look ...
nils@nilstng:~/Downloads$ dpkg -c magma_1.8.0-1661850050-5221f975_amd64.deb | grep "var/opt/magma/ebpf"
drwxr-xr-x 0/0 0 2022-08-30 11:05 ./var/opt/magma/ebpf/
-rw-r--r-- 0/0 3235 2022-08-30 09:09 ./var/opt/magma/ebpf/ebpf_ul_handler.c
drwxr-xr-x 0/0 0 2022-08-30 11:05 ./var/opt/magma/ebpf/kernsnoopd/
-rw-r--r-- 0/0 2336 2022-08-30 09:09 ./var/opt/magma/ebpf/kernsnoopd/byte_count.bpf.c
-rw-r--r-- 0/0 1042 2022-08-30 09:09 ./var/opt/magma/ebpf/kernsnoopd/common.bpf.h
-rw-r--r-- 0/0 2730 2022-08-30 09:09 ./var/opt/magma/ebpf/ebpf_dl_handler.c
-rw-r--r-- 0/0 991 2022-08-30 09:09 ./var/opt/magma/ebpf/BUILD.bazel
-rw-r--r-- 0/0 12416 2022-08-30 09:09 ./var/opt/magma/ebpf/ebpf_manager.py
nils@nilstng:~/Downloads$ dpkg -c magma_1.8.0-1661850050-5221f975_amd64.deb | grep "usr/local/lib/python3.8/dist-packages/magma/kernsnoopd"
drwxrwxr-x 0/0 0 2022-08-30 11:05 ./usr/local/lib/python3.8/dist-packages/magma/kernsnoopd/
-rw-r--r-- 0/0 1465 2022-08-30 09:09 ./usr/local/lib/python3.8/dist-packages/magma/kernsnoopd/main.py
-rw-r--r-- 0/0 853 2022-08-30 09:09 ./usr/local/lib/python3.8/dist-packages/magma/kernsnoopd/metrics.py
-rw-r--r-- 0/0 7578 2022-08-30 09:09 ./usr/local/lib/python3.8/dist-packages/magma/kernsnoopd/handlers.py
-rw-r--r-- 0/0 476 2022-08-30 09:09 ./usr/local/lib/python3.8/dist-packages/magma/kernsnoopd/__init__.py
-rw-r--r-- 0/0 4271 2022-08-30 09:09 ./usr/local/lib/python3.8/dist-packages/magma/kernsnoopd/snooper.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed
bazel/runfiles.bzl
Outdated
# lte/protos/target_name/lte/protos/foo_pb2.py -> lte/protos/foo_pb2.py | ||
return path.replace(prefix, "", 1).replace(file.owner.name + "/", "", 1) | ||
|
||
print("Unhandle path: " + path) # buildifier: disable=print |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick:
print("Unhandle path: " + path) # buildifier: disable=print | |
print("Unhandled path: " + path) # buildifier: disable=print |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed
# Contributed to https://github.com/aspect-build/rules_container under Apache-2.0 | ||
|
||
""" | ||
This file represents a workaround for the current state of https://github.com/bazelbuild/rules_pkg. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will it not be necessary any more in future versions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would hope so ... there are a couple of open upstream issues where this topic is discussed (iirc some are open for several years).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think one argument is that python files should be pre-package, e.g., into a zip and then package the zip files. Problem here is that we have redundancy in our services. E.g., proto files (small) but also pip dependencies (and these sum up). This approach results in very large magma.debs (>2gb) ans also has other disadvantages during runtime (the zips are unpacked in a tmp folder - each time the service restarts).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me the tests
//lte/gateway/python/integ_tests/s1aptests:test_attach_service_with_multi_pdns_and_bearers_mt_data
//lte/gateway/python/integ_tests/s1aptests:test_attach_dl_udp_data
keep failing with an assertion error, can you reproduce this?
Unfortunately the standard query for deps, e.g. bazel query 'filter("(^[^@])", filter("^(?!.*external)", deps(//lte/gateway/release:magma_deb_pkg)))' --output graph | dot -Tsvg > magma_deb.svg
does not work here. Is there a way to query the bazel structure of the package?
a64156e
to
aeb3258
Compare
@LKreutzer it works for me (it's just very very large and the resulting graph might not be a good visual aid) - what issue do you encounter? |
@LKreutzer they were really unstable for me too - after restarting the trf server several times they became stable
|
@sebathomas by the last commit the size of the debian package was decreased from 930mb to 390mb. This was possible because before we added debug symbols not only to the magma binaries, but also to the external dependencies. we might want to do further analysis if the size can be optimized, but I suggest to do this as follow-up tasks. |
9c2458a
to
ca5e4d2
Compare
precommit tests on latest artifact:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pkg_mklink( | ||
name = "pipelined_symlink", | ||
link_name = "/etc/magma/pipelined.yml", | ||
target = "/etc/magma/pipelined.yml_prod", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we just store pipelined.yml_prod
at /etc/magma/pipelined.yml
instead of symlinking?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be possible, yes - for now this is the behavior of the make created .deb.
I can only speculate: I assume the reason is/was, to have a convenient way to switch between prod and test setups.
Wow, that makes huge difference. Good catch! |
ca5e4d2
to
4bf94bd
Compare
Signed-off-by: Nils Semmelrock <nils.semmelrock@tngtech.com>
Signed-off-by: Nils Semmelrock <nils.semmelrock@tngtech.com>
Signed-off-by: Nils Semmelrock <nils.semmelrock@tngtech.com>
Signed-off-by: Nils Semmelrock <nils.semmelrock@tngtech.com>
Signed-off-by: Nils Semmelrock <nils.semmelrock@tngtech.com>
Signed-off-by: Nils Semmelrock <nils.semmelrock@tngtech.com>
Signed-off-by: Nils Semmelrock <nils.semmelrock@tngtech.com>
Signed-off-by: Nils Semmelrock <nils.semmelrock@tngtech.com>
Signed-off-by: Nils Semmelrock <nils.semmelrock@tngtech.com>
Signed-off-by: Nils Semmelrock <nils.semmelrock@tngtech.com>
Signed-off-by: Nils Semmelrock <nils.semmelrock@tngtech.com>
Signed-off-by: Nils Semmelrock <nils.semmelrock@tngtech.com>
Signed-off-by: Nils Semmelrock <nils.semmelrock@tngtech.com>
…ifacts is decreased) Signed-off-by: Nils Semmelrock <nils.semmelrock@tngtech.com>
4bf94bd
to
d500c9d
Compare
Summary
This change introduces a first throw for a magma debian build with bazel.
known issues
(~900mb)
and with--config=production
even largerTest Plan
or bazelBase/devcontainer(the bazelBase/devcontainer sessiond services is currently not compatible with magma_deb)bazel build //lte/gateway/release:magma_deb_pkg
--config=production
to be closer to the make debian buildnote: in rebuild the vscode container setup because of recent needed changes (fix: bazel base uses same folly version as magma vm #13743)~/magma$ cp bazel-bin/lte/gateway/release/magma_1.8.0_amd64.deb .
lte/gateway/deploy/roles/magma_deploy/tasks/main.yml
modify "Installing magma."# name: "{{ packages }}"
deb: "/home/vagrant/magma/magma_1.8.0_amd64.deb"
~/magma/lte/gateway$ vagrant up magma_deb
magma_deb
for issues, services running, logging, ...magma_deb
Additional Information