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

Refactor bpf loader #864

Merged
merged 10 commits into from
Oct 10, 2024
Merged

Refactor bpf loader #864

merged 10 commits into from
Oct 10, 2024

Conversation

hzxuzhonghu
Copy link
Member

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

make the bpf loader more readable and deduplicate error handling

Which issue(s) this PR fixes:
Fixes #858

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


Copy link

codecov bot commented Sep 18, 2024

Codecov Report

Attention: Patch coverage is 58.33333% with 195 lines in your changes missing coverage. Please review.

Project coverage is 54.58%. Comparing base (390e845) to head (832964e).
Report is 41 commits behind head on main.

Files with missing lines Patch % Lines
pkg/bpf/workload/sock_connection.go 62.26% 22 Missing and 18 partials ⚠️
pkg/bpf/workload/sendmsg.go 58.62% 18 Missing and 18 partials ⚠️
pkg/bpf/workload/sock_ops.go 59.49% 16 Missing and 16 partials ⚠️
pkg/bpf/workload/xdp.go 54.54% 12 Missing and 13 partials ⚠️
pkg/bpf/bpf.go 43.24% 12 Missing and 9 partials ⚠️
pkg/bpf/ads/loader.go 53.12% 7 Missing and 8 partials ⚠️
pkg/bpf/workload/loader.go 56.25% 0 Missing and 14 partials ⚠️
pkg/bpf/ads/sock_connection.go 37.50% 0 Missing and 5 partials ⚠️
pkg/bpf/restart/bpf_restart.go 66.66% 3 Missing ⚠️
pkg/controller/workload/workload_controller.go 0.00% 2 Missing ⚠️
... and 2 more
Files with missing lines Coverage Δ
pkg/bpf/utils/bpf_helper.go 100.00% <100.00%> (ø)
pkg/bpf/utils/pin.go 57.57% <100.00%> (ø)
pkg/cache/v2/maps/cluster.go 56.09% <ø> (ø)
pkg/cache/v2/maps/common.go 56.09% <ø> (ø)
pkg/controller/client.go 65.43% <100.00%> (ø)
pkg/controller/workload/workload_processor.go 61.76% <ø> (ø)
pkg/utils/test/bpf_map.go 37.14% <100.00%> (-4.97%) ⬇️
pkg/controller/controller.go 0.00% <0.00%> (ø)
pkg/status/status_server.go 42.30% <0.00%> (ø)
pkg/controller/workload/workload_controller.go 62.74% <0.00%> (ø)
... and 9 more

... and 4 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bff5b9a...832964e. Read the comment docs.


if err := sc.Load(); err != nil {
if errors.As(err, &ve) {
return fmt.Errorf("bpf load failed: %+v", ve)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this action to give a more accurate error message?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think so, this is recently added by @weli-l otherwise the error info is truncated

}

func NewBpfKmesh(cfg *options.BpfConfig) (*BpfAds, error) {
var err error
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove

}

func (sc *BpfAds) Load() error {
var err error
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove

}

func (sc *BpfAds) Attach() error {
var err error
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto

@hzxuzhonghu hzxuzhonghu changed the title WIP: Refactor bpf loader Refactor bpf loader Sep 19, 2024
@hzxuzhonghu
Copy link
Member Author

/assign @lec-bit

Signed-off-by: Zhonghu Xu <[email protected]>
Signed-off-by: Zhonghu Xu <[email protected]>
Signed-off-by: Zhonghu Xu <[email protected]>
Signed-off-by: Zhonghu Xu <[email protected]>
Signed-off-by: Zhonghu Xu <[email protected]>
Signed-off-by: Zhonghu Xu <[email protected]>
Signed-off-by: Zhonghu Xu <[email protected]>
Signed-off-by: Zhonghu Xu <[email protected]>
@hzxuzhonghu
Copy link
Member Author

cc @nlgwcy

@nlgwcy
Copy link
Contributor

nlgwcy commented Oct 10, 2024

/lgtm
/approve

@kmesh-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: nlgwcy

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kmesh-bot kmesh-bot merged commit 99e0c0c into kmesh-net:main Oct 10, 2024
9 checks passed
@hzxuzhonghu hzxuzhonghu deleted the bpf-loader branch October 10, 2024 11:42
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.

Improve maintainability of bpf loader
5 participants