Skip to content

Commit

Permalink
Add the ability to get process cache entries
Browse files Browse the repository at this point in the history
This will be used in follow-up PRs for creating tests check process cache entries.

Signed-off-by: Anastasios Papagiannis <[email protected]>
  • Loading branch information
tpapagian committed Jan 28, 2025
1 parent 9988b44 commit 5e46dc7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
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()
}

0 comments on commit 5e46dc7

Please sign in to comment.