-
Notifications
You must be signed in to change notification settings - Fork 69
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
support dump workload bpf map #853
Conversation
Signed-off-by: [email protected] <[email protected]>
daaec4a
to
4277510
Compare
since we have some problems in ads bpf map deserialization, i first implemented the workload bpf map. |
Signed-off-by: [email protected] <[email protected]>
4277510
to
1590ec6
Compare
Signed-off-by: [email protected] <[email protected]>
614f7c3
to
4690cb6
Compare
WIP, exists some erros |
Signed-off-by: [email protected] <[email protected]>
Great. let me try |
pkg/status/status_server.go
Outdated
func (s *Server) bpfAdsMaps(w http.ResponseWriter, r *http.Request) { | ||
client := s.xdsClient | ||
if client == nil || client.AdsController == nil { | ||
w.WriteHeader(http.StatusBadRequest) | ||
fmt.Fprintf(w, "\t%s\n", "invalid ClientMode") | ||
fmt.Fprint(w, invalidModeErrMessage) |
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 could also wrap it into a function like checkAdsMode()
pkg/status/status_server.go
Outdated
@@ -257,7 +309,7 @@ func (s *Server) configDumpAds(w http.ResponseWriter, r *http.Request) { | |||
client := s.xdsClient | |||
if client == nil || client.AdsController == nil { | |||
w.WriteHeader(http.StatusBadRequest) | |||
fmt.Fprintf(w, "\t%s\n", "invalid ClientMode") | |||
fmt.Fprint(w, invalidModeErrMessage) |
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.
ditto
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.
ok
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.
Overall lgtm
|
||
func (c *Cache) WorkloadPolicyLookupAll() []WorkloadPolicy_value { | ||
log.Debugf("WorkloadPolicyLookupAll") | ||
return LookupAll[WorkloadPolicy_key, WorkloadPolicy_value](c.bpfMap.MapOfWlPolicy) |
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: WorkloadPolicy_key WorkloadPolicy_value should be camel format
@@ -0,0 +1,19 @@ | |||
package bpfcache |
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.
copyright is missing
"github.com/cilium/ebpf" | ||
) | ||
|
||
func LookupAll[K any, V any](bpfMap *ebpf.Map) []V { |
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.
good generic function
pkg/status/status_server.go
Outdated
@@ -46,6 +47,7 @@ const ( | |||
patternHelp = "/help" | |||
patternOptions = "/options" | |||
patternBpfAdsMaps = "/debug/bpf/ads" | |||
patternBpfWorkloadMaps = "/debug/bpf/workload" |
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.
how about /debug/config_dump/bpf/workload
and /debug/config_dump/bpf/ads
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.
seems good
Signed-off-by: [email protected] <[email protected]>
17821b5
to
30126b4
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.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: hzxuzhonghu 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 |
What type of PR is this?
feature
What this PR does / why we need it:
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?: