-
Notifications
You must be signed in to change notification settings - Fork 15
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
bpfman-operator: Support Load/Attach Split #347
base: main
Are you sure you want to change the base?
Conversation
e352df4
to
0531a5f
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #347 +/- ##
=======================================
Coverage ? 31.27%
=======================================
Files ? 66
Lines ? 7630
Branches ? 0
=======================================
Hits ? 2386
Misses ? 5028
Partials ? 216
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
113089c
to
60d0115
Compare
All of the examples will need to be updated with the new CRD format before the Kubernetes integration tests will pass. |
@anfredette, this pull request is now in conflict and requires a rebase. |
083793b
to
5dce708
Compare
5dce708
to
94b2131
Compare
@anfredette, this pull request is now in conflict and requires a rebase. |
94b2131
to
8bf9338
Compare
10366ab
to
0c7f942
Compare
0c7f942
to
218f890
Compare
@anfredette, this pull request is now in conflict and requires a rebase. |
This is still a WIP, but it's working for cluster-scoped XDP programs. Here's a sample of the kubectl output from installing and deleting an XDP program: If you're looking at the code, the new operator and agent code is in the app-operator and app-agent directories, while the old code is still in bpfman-operator and bpfman-agent. I plan to eventually delete the old directories and rename the new ones, but I'm keeping the old code around for comparison and to pull from as needed. |
2799666
to
d68ab2a
Compare
a068f54
to
83561f6
Compare
69a1b95
to
9e5cb54
Compare
@anfredette, this pull request is now in conflict and requires a rebase. |
52f83b1
to
45dabcc
Compare
45dabcc
to
3174166
Compare
@anfredette, this pull request is now in conflict and requires a rebase. |
cd9642e
to
fe2ed08
Compare
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.
Some feedback on the API. The naming comments we can probably handle in a follow up as this API change isn't going to be backwards compatible anyway.
We should however fix the fentry/fexit and preferably drop type: Xdp
before merge IMHO
PROJECT
Outdated
controller: true | ||
domain: bpfman.io | ||
kind: TcxNsProgram | ||
kind: BpfNsApplication |
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.
We agreed this would be BpfApplication
and ClusterBpfApplication
But IIRC we wanted to get Billy's change in first before we changed the naming since this API change is the breaking one.
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.
Done
PROJECT
Outdated
controller: true | ||
domain: bpfman.io | ||
kind: BpfNsApplication | ||
kind: BpfNsApplicationState |
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.
So this would then be ClusterBpfApplicationState
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.
Done
programs: | ||
- type: Kprobe | ||
- bpffunctionname: kprobe_test |
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 really don't like bpffunctioname
. It should either be bpfFunctionName
or just functionName
since we're in a Bpf
CRD.. or hey, even just function
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.
We made it "bpffunctionname" after much discussion a while back when we started using the bpf function name instead of a name defined in the section declaration. We also wanted to disambiguate this function name from the name of the function that some bpf programs attach to.
That said, I don't like it either :-). I changed "bpfunctionname" to just "name", and the "func_name" and "function_name" to just "function".
programs: | ||
- type: Kprobe | ||
- bpffunctionname: kprobe_test | ||
type: Kprobe |
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.
Just wondering, is case significant here? It seems to me that kprobe
or KPROBE
or Kprobe
should probably work. I'd prefer to use the lowercase version.
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.
Yes and no. Left unchecked, I don't think Kubernetes would care, but it is case sensitive in that kubernetes passes these values through to the controller code in the case that the user enters them. However, we also have validation logic that only allows one case, so in our case (no pun intended) it is case sensitive. If we wanted to support case insensitivity, we'd have to handle it in our code.
I made everything lower case. We can disuss whether to use camelCase instead.
offset: 0 | ||
retprobe: false | ||
- bpffunctionname: kretprobe_test | ||
type: Kprobe |
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.
Do we need to expose type
here?
It can be inferred based on which of the optional fields are set so it seems redundant
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.
This is implemented this as union, and Type is the "unionDiscriminator". This tells us which of the "unionMembers" will be populated, and validation logic ensures that if the Type is X, the program info for X is populated. @msherif1234 used this pattern for the original BpfApplication CRD. There may be another way to implement the API, but this works.
priority: 55 | ||
direction: ingress | ||
- type: TCX | ||
attach_points: |
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 this should be links
as we're expressing desired state.
The verb might be attach
, but we're expecting links
in the end.
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.
Done
offset: 0 | ||
retprobe: false | ||
- type: Tracepoint | ||
attach_points: |
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.
👀 inconsistent rules re: casing. k8s CRDs are supposed to be camelCase
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.
Is the JSON representation supposed to be camelCase?
retprobe: false | ||
- type: Tracepoint | ||
attach_points: | ||
- func_name: try_to_wake_up |
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.
as above: funcName
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.
It's now just function
direction: ingress | ||
- type: TCX | ||
attach_points: | ||
- interfaceselector: |
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.
interfaceSelector
. I'm not going to comment on this anymore.
We seriously need to take a pass through the API to fix the inconsistencies.
We can do that in this PR, or later
- bpffunctionname: fentry_test | ||
type: Fentry | ||
fentry: | ||
function_name: do_unlinkat | ||
attach: true |
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.
- bpffunctionname: fentry_test | |
type: Fentry | |
fentry: | |
function_name: do_unlinkat | |
attach: true | |
- function: fentry_test | |
fentry: | |
links: | |
- function_name: do_unlinkat |
This shouldn't deviate from the pattern in the other program types.
The fact we need the fn_name for load()
and we can only attach it to one place are implementation details we shouldn't be exposing in the API.
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.
Fentry and Fexit now follow the same pattern (mostly).
@anfredette, this pull request is now in conflict and requires a rebase. |
c919dac
to
abaee3e
Compare
d28f8a9
to
8e72399
Compare
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.
not sure about renaming the agent files with cl
is that for clusterscope ?
@@ -42,15 +42,9 @@ const ( | |||
// ProgTypeKprobe refers to the Kprobe program type. | |||
ProgTypeKprobe EBPFProgType = "Kprobe" | |||
|
|||
// ProgTypeKretprobe refers to the Kprobe program type. | |||
ProgTypeKretprobe EBPFProgType = "Kretprobe" | |||
|
|||
// ProgTypeUprobe refers to the Uprobe program type. |
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 don't know why u deleted the kproberet and uproberet program types ?
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.
They weren't being used.
apis/v1alpha1/shared_types.go
Outdated
// MapOwnerSelector is used to select the loaded eBPF program this eBPF program | ||
// will share a map with. The value is a label applied to the BpfProgram to select. | ||
// The selector must resolve to exactly one instance of a BpfProgram on a given node | ||
// or the eBPF program will not load. |
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.
we no longer have an object called BpfProgram
so we should avoid using it everywhere in code and comments
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 got rid of a lot of it, but there's still more work to do.
return nil, fmt.Errorf("failed to get container pids: %v", err) | ||
} | ||
|
||
if containerInfo != nil && len(*containerInfo) != 0 { |
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.
nit no need to check the len range will handle that
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.
Done.
8e72399
to
abb5fef
Compare
Yes. I was planning to rename things as follows: |
020133b
to
ca275d1
Compare
This commit introduces support for bpfman’s load-attach split from bpfman PR refactoring and CRD changes to align with this new model. Key Changes: - Remove "*Program" CRDs and related code in favor of the BpfApplication CRD, which can contain multiple eBPF programs. - Replace BpfProgram CRD with BpfApplicationState, which stores per-node state information for all eBPF programs in a BpfApplication. - Rename CRDs for better alignment with Kubernetes conventions: - BpfApplication => ClusterBpfApplication (Cluster-scoped) - BpfNsApplication => BpfApplication (Namespace-scoped) - The BpfApplication CRDs have been modified to include an optional list of attach points for each program, enabling pre-loading programs before attachment and supporting dynamic attachment updates. - Redesign the bpfman-agent controller to natively support BpfApplications. Signed-off-by: Andre Fredette <[email protected]>
ca275d1
to
7b5041c
Compare
This commit introduces support for bpfman’s load-attach split from bpfman PR
#1354 and includes major
refactoring and CRD changes to align with this new model.
Key Changes:
which can contain multiple eBPF programs.
information for all eBPF programs in a BpfApplication.
attach points for each program, enabling pre-loading programs before
attachment and supporting dynamic attachment updates.