-
Notifications
You must be signed in to change notification settings - Fork 118
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
Add support for generating non-bpf files #1710
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1710 +/- ##
==========================================
- Coverage 69.72% 68.57% -1.15%
==========================================
Files 210 211 +1
Lines 21282 21635 +353
==========================================
- Hits 14838 14837 -1
- Misses 5716 6070 +354
Partials 728 728
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
Looks great, I left a few questions and suggestions.
generate: export BPF2GO := $(BPF2GO) | ||
generate: bpf2go | ||
@echo "### Generating files..." | ||
@BEYLA_GENFILES_RUN_LOCALLY=1 go generate cmd/beyla-genfiles/beyla_genfiles.go |
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.
Does run_locally use the local clang/llvm instead of a Docker image?
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.
correct, that is exactly it
cmd/beyla-genfiles/beyla_genfiles.go
Outdated
const OCI_BIN = "docker" | ||
const GEN_IMG = "ghcr.io/grafana/beyla-ebpf-generator:main" | ||
const OCIBin = "docker" | ||
const GenImg = "ghcr.io/grafana/beyla-ebpf-generator:main" |
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 this cause us issues with releases? What I mean is that, if by some reason we drift the n.n.n release generation from main, would we still be able to compile the binaries on release update?
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.
Usually not - one of the goals of this PR is to actually delegate the entire logic of binary generation and what not to this script - the docker image simply does this:
BEYLA_GENFILES_RUN_LOCALLY=1 go run cmd/beyla-genfiles/beyla_genfiles.go
i.e. once inside the container, it just reinvokes this with the "locally" flag (in which case locally is now "inside the container").
What I do intend to do nonetheless (but if possible as a new PR sometime soon), is to version the image, if push comes to shove. Ultimately this could be made as an env var, and once we release, we can publish/tag different generator images.
This PR generalises the concept brought forth by
build_ebpf.go
into a tool that can be run standalone, and will generate every//go:generate
tag for Beyla.Projects that have a dependency on beyla (such as Alloy) can now simply run:
as part of their build process, simplifying their workflow.
Finally, it simplifies the generator image, which now simply relies on
beyla-genfiles
to do the work (and build in parallel).Usage in Alloy: grafana/alloy#2734