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

Add the ability to get process cache entries #3348

Merged
merged 1 commit into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions pkg/process/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,16 @@ func (pc *Cache) dump(opts *tetragon.DumpProcessCacheReqArgs) []*tetragon.Proces
}
return processes
}

func (pc *Cache) getEntries() []*tetragon.ProcessInternal {
var processes []*tetragon.ProcessInternal
for _, v := range pc.cache.Values() {
processes = append(processes, &tetragon.ProcessInternal{
Process: v.process,
Refcnt: &wrapperspb.UInt32Value{Value: v.refcnt},
RefcntOps: v.refcntOps,
Color: colorStr[v.color],
})
}
return processes
}
9 changes: 9 additions & 0 deletions pkg/process/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,3 +532,12 @@ func GetK8s() watcher.K8sResourceWatcher {
func DumpProcessCache(opts *tetragon.DumpProcessCacheReqArgs) []*tetragon.ProcessInternal {
return procCache.dump(opts)
}

// This function returns the process cache entries (and not the copies
// of them as opposed to dump function). Thus any changes to the return
// value results in affecting the process cache entries.
// This is mainly for tests where we want to check the values of the
// process cache.
func GetCacheEntries() []*tetragon.ProcessInternal {
return procCache.getEntries()
}
Loading