Skip to content

Conversation

@anfredette
Copy link
Contributor

@anfredette anfredette commented Dec 9, 2024

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:

  • 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.

This code can be executed on KIND with the following command:

BPFMAN_IMG="quay.io/afredette/bpfman:latest" make run-on-kind

Fixes: #397

@anfredette anfredette force-pushed the load-attach-split branch 2 times, most recently from e352df4 to 0531a5f Compare December 10, 2024 22:15
@codecov
Copy link

codecov bot commented Dec 10, 2024

Codecov Report

Attention: Patch coverage is 0% with 789 lines in your changes missing coverage. Please review.

Project coverage is 31.69%. Comparing base (d60c342) to head (e36ff6e).
Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
apis/v1alpha1/zz_generated.deepcopy.go 0.00% 690 Missing ⚠️
apis/v1alpha1/shared_types.go 0.00% 42 Missing ⚠️
cmd/bpfman-operator/main.go 0.00% 16 Missing ⚠️
apis/v1alpha1/bpf_application_state_types.go 0.00% 14 Missing ⚠️
...is/v1alpha1/cluster_bpf_application_state_types.go 0.00% 14 Missing ⚠️
cmd/bpfman-agent/main.go 0.00% 7 Missing ⚠️
apis/v1alpha1/zz_generated.register.go 0.00% 6 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #347       +/-   ##
===========================================
+ Coverage   18.67%   31.69%   +13.01%     
===========================================
  Files         128       66       -62     
  Lines       11211     7794     -3417     
===========================================
+ Hits         2094     2470      +376     
+ Misses       8909     5097     -3812     
- Partials      208      227       +19     
Flag Coverage Δ
unittests 31.69% <0.00%> (+13.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@anfredette anfredette force-pushed the load-attach-split branch 2 times, most recently from 113089c to 60d0115 Compare December 10, 2024 22:31
@anfredette
Copy link
Contributor Author

anfredette commented Dec 10, 2024

All of the examples will need to be updated with the new CRD format before the Kubernetes integration tests will pass.

@mergify
Copy link
Contributor

mergify bot commented Dec 18, 2024

@anfredette, this pull request is now in conflict and requires a rebase.

@mergify
Copy link
Contributor

mergify bot commented Jan 9, 2025

@anfredette, this pull request is now in conflict and requires a rebase.

@mergify mergify bot added the needs-rebase label Jan 9, 2025
@mergify mergify bot removed the needs-rebase label Jan 9, 2025
@anfredette anfredette force-pushed the load-attach-split branch 2 times, most recently from 10366ab to 0c7f942 Compare January 9, 2025 14:57
@mergify
Copy link
Contributor

mergify bot commented Jan 22, 2025

@anfredette, this pull request is now in conflict and requires a rebase.

@mergify mergify bot added the needs-rebase label Jan 22, 2025
@anfredette anfredette changed the title WIP: Initial pass at BpfApplication CRD update for load/attach split WIP: New bpfman-operator design and CRDs to support the load/attach split Jan 22, 2025
@anfredette
Copy link
Contributor Author

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:
https://gist.github.com/anfredette/4433aaa58518db5d4d14ed2bf4218f55

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.

@anfredette anfredette force-pushed the load-attach-split branch 2 times, most recently from 2799666 to d68ab2a Compare January 22, 2025 17:19
@mergify mergify bot removed the needs-rebase label Jan 22, 2025
@anfredette anfredette changed the title WIP: New bpfman-operator design and CRDs to support the load/attach split Initial bpfman-operator support for Load/Attach Split Jan 23, 2025
@anfredette anfredette force-pushed the load-attach-split branch 3 times, most recently from 69a1b95 to 9e5cb54 Compare January 24, 2025 22:51
Copy link
Contributor

@msherif1234 msherif1234 left a 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 ?

// ProgTypeKretprobe refers to the Kprobe program type.
ProgTypeKretprobe EBPFProgType = "Kretprobe"

// ProgTypeUprobe refers to the Uprobe program type.
Copy link
Contributor

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 ?

Copy link
Contributor Author

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.

// 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.
Copy link
Contributor

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

Copy link
Contributor Author

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 {
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@anfredette
Copy link
Contributor Author

not sure about renaming the agent files with cl is that for clusterscope ?

Yes. I was planning to rename things as follows:
cluster-scoped related files: cl_*
namespace-scoped related files: ns_*

@anfredette anfredette force-pushed the load-attach-split branch 2 times, most recently from 020133b to ca275d1 Compare March 2, 2025 22:42
@anfredette anfredette changed the title Initial bpfman-operator support for Load/Attach Split bpfman-operator: Support Load/Attach Split Mar 2, 2025
@anfredette anfredette force-pushed the load-attach-split branch 5 times, most recently from 3b22722 to 4f5cce2 Compare March 3, 2025 20:56
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.

Fixes: bpfman#397

Signed-off-by: Andre Fredette <[email protected]>
anfredette added a commit to anfredette/bpfman-operator that referenced this pull request Mar 4, 2025
Also cleaned up a couple of log messages.

Fixes: bpfman#347

Signed-off-by: Andre Fredette <[email protected]>
Also cleaned up a couple of log messages.

Fixes: bpfman#398

Signed-off-by: Andre Fredette <[email protected]>
@anfredette anfredette marked this pull request as ready for review March 4, 2025 22:36
@anfredette anfredette force-pushed the load-attach-split branch 2 times, most recently from ade3ce8 to 9927f56 Compare March 5, 2025 01:47
- Add missing license declaration.
- Fixed up some copyright statements.
- Turn cosign verification back on
- Ran go mod tidy and vendor

Signed-off-by: Andre Fredette <[email protected]>
anfredette and others added 2 commits March 5, 2025 11:15
Signed-off-by: Mohamed Mahmoud <[email protected]>
Copy link
Contributor

@Billy99 Billy99 left a comment

Choose a reason for hiding this comment

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

Work needs to be done on the integration tests. Merging with integration tests failing and work off main to get tests passing again.

@Billy99 Billy99 merged commit a5cbbbe into bpfman:main Mar 5, 2025
12 of 13 checks passed
msherif1234 pushed a commit to msherif1234/bpfman-operator that referenced this pull request Mar 27, 2025
…ithub.com-openshift-api-digest

fix(deps): update github.com/openshift/api digest to 635291d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement bpfman-operator support for the bpfman load-attach-split change

4 participants