Skip to content
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

bazel: use a sysroot for compilation #24669

Open
wants to merge 8 commits into
base: dev
Choose a base branch
from

Conversation

rockwotj
Copy link
Contributor

@rockwotj rockwotj commented Jan 2, 2025

This patchset is two fold:

First and foremost we have a hermetic sysroot we compile against for all builds so now system dependencies should not leak into the build, and we can define them from a docker image. This means we can remove some dependencies from the install-deps.sh script.

Secondly, wire up a docker image that can run the broker using the ultra slim distroless series of containers. There is probably more we can do on the packaging front, but this is a good step. I moved the LD_LIBRARY_PATH script to a golang binary since bash is not installed on the distroless images. I'm also thinking that we could move completely to the base image that distroless provides (no shared libraries present), then copy in our shared libraries from our sysroot, but I'm punting on that for now.

Backports Required

  • none - not a bug fix
  • none - this is a backport
  • none - issue does not exist in previous branches
  • none - papercut/not impactful enough to backport
  • v24.3.x
  • v24.2.x
  • v24.1.x

Release Notes

  • none

@rockwotj rockwotj force-pushed the bazel-image branch 3 times, most recently from 8b02ac6 to 4e111a9 Compare January 3, 2025 19:39
@rockwotj rockwotj marked this pull request as ready for review January 3, 2025 19:39
@rockwotj rockwotj force-pushed the bazel-image branch 3 times, most recently from 2b99fef to 4430087 Compare January 3, 2025 20:09
@rockwotj rockwotj requested review from dotnwat and removed request for twmb, Deflaimun, r-vasquez and gene-redpanda January 3, 2025 20:12
dotnwat
dotnwat previously approved these changes Jan 3, 2025
MODULE.bazel Show resolved Hide resolved
MODULE.bazel Show resolved Hide resolved
bazel/toolchain/Dockerfile.sysroot Show resolved Hide resolved
Big picture:

* Use Distroless containers from Google to have a minimal base image
* Since we don't have bash in these containers change our
  LD_LIBRARY_PATH loader script to static Golang binaries
* Mimic the layout/functionality of our existing images

We don't package host shared libraries (glibc, libgcc) however, so we
still need a solution to package those up, ideally with a clang sysroot.
Provide a sysroot from an ubuntu jammy docker image to provide a
consistent set of headers, and system libraries for us to use to
build Redpanda. This way there should be less differences between
machines and we can remove a couple of required packages for
development.
Required to pull in fixes for a custom sysroot
@rockwotj rockwotj requested a review from a team as a code owner January 9, 2025 05:04
@rockwotj rockwotj requested review from andrewhsu and removed request for a team January 9, 2025 05:04
@vbotbuildovich
Copy link
Collaborator

CI test results

test results on build#60473
test_id test_kind job_url test_status passed
gtest_raft_rpunit.gtest_raft_rpunit unit https://buildkite.com/redpanda/redpanda/builds/60473#01944974-5dff-47fe-8561-0446bc3dc9bd FLAKY 1/2
rptest.tests.partition_balancer_test.PartitionBalancerTest.test_fuzz_admin_ops ducktape https://buildkite.com/redpanda/redpanda/builds/60473#019449cf-8f7f-470e-b3c8-864e343eda36 FLAKY 5/6
rptest.tests.partition_reassignments_test.PartitionReassignmentsTest.test_reassignments_kafka_cli ducktape https://buildkite.com/redpanda/redpanda/builds/60473#019449cc-02e0-49c6-b7d1-cbee8d21fddf FLAKY 4/6

@rockwotj
Copy link
Contributor Author

rockwotj commented Jan 9, 2025

CI is failing with the reduced set of packages installed in the docker container because there is no longer a system python interpreter. The latest commit fixes our python3 binaries to use the Bazel toolchain instead.

Without this one neat trick, genrules are using the system python3 to
run these python scripts (which are chmod +x python files with
 #!/usr/bin/env python3 at the top). This change explicitly uses the
Bazel toolchain. We must switch to the bazel toolchain because after
removing valgrind from the list of system packages in `install-deps.sh`
there is no longer python available in the docker image we build with.
It's better this way anyways.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants