kmesh-net / kmesh

High Performance ServiceMesh Data Plane Based on Programmable Kernel
https://kmesh.net
Apache License 2.0
362 stars 46 forks source link

Kmesh eBPF log user space dumping #402

Closed bfforever closed 2 weeks ago

bfforever commented 1 month ago

What type of PR is this? /kind feature /kind enhancement

What this PR does / why we need it:

  1. Kmesh eBPF log user space dumping. version > 5.13 dump bpf log to userspace, otherwise print log in trace pipe.

  2. Support dynamic bpf log level. k exec ds/kmesh -n kmesh-system -- curl -s localhost:15200/debug/bpfLogLevel/3

Which issue(s) this PR fixes: Fixes 388

Special notes for your reviewer: bpf_log_3

Does this PR introduce a user-facing change?:

When print bpf log to kmesh daemon process or user space, just use BPF_LOG_U instead of BPF_LOG, the args which input is same as BPF_LOG.

codecov-commenter commented 1 month ago

Codecov Report

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

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Flag Coverage Δ
unittests 36.41% <0.00%> (+4.40%) :arrow_up:

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

Files Coverage Δ
pkg/controller/controller.go 0.00% <0.00%> (ø)
pkg/status/status_server.go 13.22% <0.00%> (-2.32%) :arrow_down:
pkg/logger/logger.go 34.42% <0.00%> (-56.88%) :arrow_down:

... and 6 files with indirect coverage changes

bfforever commented 3 weeks ago

can we use bpf_snprintf_btf, which is supported since 5.10

Possiblely can't, I see this function use to render type info with type value of a certain struct, to output a string, not provide format capability.

bfforever commented 2 weeks ago

/hold

bfforever commented 2 weeks ago

/unhold

nlgwcy commented 2 weeks ago

Good Job~ The following two points can be optimized in the future:

  1. byte order conversion in ip2str can be extracted.
  2. execute ip2str according to the log level. (e.g: IP2STR_ON_ERR/IP2STR_ON_DBG/...)
nlgwcy commented 2 weeks ago

/lgtm /approve

kmesh-bot commented 2 weeks ago

[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: - ~~[OWNERS](https://github.com/kmesh-net/kmesh/blob/main/OWNERS)~~ [nlgwcy] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
bfforever commented 1 week ago

Good Job~ The following two points can be optimized in the future:

  1. byte order conversion in ip2str can be extracted.
  2. execute ip2str according to the log level. (e.g: IP2STR_ON_ERR/IP2STR_ON_DBG/...)

Okay.

hzxuzhonghu commented 1 week ago

can you add a document on this feature to website https://kmesh.net/en/docs/

bfforever commented 1 week ago

can you add a document on this feature to website https://kmesh.net/en/docs/

Of course.