Skip to content

Conversation

sayboras
Copy link
Member

@sayboras sayboras commented Jun 12, 2025

Description

This is to make sure that we don't rely on import statement and generate the files in unintended directory.

For example, dummy import in bpf.proto, followed by make codegen will generate files into google/protobuf instead of tetragon dir

diff --git i/api/v1/tetragon/bpf.proto w/api/v1/tetragon/bpf.proto
index 486c4ed32..08629fac3 100644
--- i/api/v1/tetragon/bpf.proto
+++ w/api/v1/tetragon/bpf.proto
@@ -5,6 +5,8 @@ syntax = "proto3";
 
 package tetragon;
 
+import "google/protobuf/duration.proto";
+
 option go_package = "github.com/cilium/tetragon/api/v1/tetragon";
 
 enum BpfCmd {
$  make protogen
... 
...
buf generate 
time="2025-06-12T03:27:25Z" level=info msg=google/protobuf/codegen/helpers/helpers.pb.go
time="2025-06-12T03:27:25Z" level=info msg=google/protobuf/codegen/eventchecker/eventchecker.pb.go
time="2025-06-12T03:27:25Z" level=info msg=google/protobuf/codegen/eventchecker/yaml/yaml.pb.go
time="2025-06-12T03:27:25Z" level=info msg=google/protobuf/types.pb.go
...

$ git status              
...
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        api/v1/google/

With this patch, I can see the generated files are in the correct directory

$ make protogen
...
time="2025-06-12T03:56:29Z" level=info msg=tetragon/codegen/helpers/helpers.pb.go
time="2025-06-12T03:56:29Z" level=info msg=tetragon/codegen/eventchecker/eventchecker.pb.go
time="2025-06-12T03:56:29Z" level=info msg=tetragon/codegen/eventchecker/yaml/yaml.pb.go
time="2025-06-12T03:56:29Z" level=info msg=tetragon/types.pb.go
...

Changelog

tools: Avoid picking protoc file randomly

@sayboras sayboras force-pushed the pr/tammach/tetragon/protoc branch from 458f08f to fc5b60d Compare June 12, 2025 03:30
@sayboras sayboras added the release-note/misc This PR makes changes that have no direct user impact. label Jun 12, 2025
@sayboras sayboras force-pushed the pr/tammach/tetragon/protoc branch from fc5b60d to 1c50e57 Compare June 12, 2025 03:32
Copy link
Contributor

@kkourt kkourt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Greatly appreciate the nice description in the PR. Could you also add it (or at least a summary of it) in the commit message as well?

@sayboras sayboras marked this pull request as ready for review June 12, 2025 07:13
@sayboras sayboras requested a review from a team as a code owner June 12, 2025 07:13
@sayboras sayboras requested a review from tixxdz June 12, 2025 07:13
@sayboras
Copy link
Member Author

Greatly appreciate the nice description in the PR. Could you also add it (or at least a summary of it) in the commit message as well?

Sure 👍

The list of protogen.File passed to tetragon plugin might contain 3rd
party files from the import statement as well. For example, if bpf.proto
imports google/protobuf/duration.proto, then generated file will be in
v1/google/protobuf instead of v1/tetragon directory.

This commit is to make sure the location is correctly derived.

Signed-off-by: Tam Mach <[email protected]>
@sayboras sayboras force-pushed the pr/tammach/tetragon/protoc branch from 1c50e57 to 5271bb8 Compare June 12, 2025 09:05
@sayboras sayboras merged commit 06365d5 into main Jun 12, 2025
46 checks passed
@sayboras sayboras deleted the pr/tammach/tetragon/protoc branch June 12, 2025 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note/misc This PR makes changes that have no direct user impact.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants