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

fix: process_execute_failed use correct lru #4283

Merged
merged 1 commit into from
Sep 9, 2024
Merged
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
16 changes: 5 additions & 11 deletions pkg/events/derive/process_execute_failed.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ import (

// ExecFailedGenerator is the object which implement the ProcessExecuteFailed event derivation
type ExecFailedGenerator struct {
execEndInfo *lru.Cache[int, execEndInfo]
baseEvents *lru.Cache[int, *trace.Event]
deriveBase deriveBase
baseEvents *lru.Cache[int, *trace.Event]
deriveBase deriveBase
}

// InitProcessExecuteFailedGenerator initialize a new generator for the ProcessExecuteFailed event.
Expand All @@ -23,18 +22,13 @@ func InitProcessExecuteFailedGenerator() (*ExecFailedGenerator, error) {
// For now, we assume that the current value is sufficient
const executionEventsCacheSize = 16

executeProcsCache, err := lru.New[int, execEndInfo](executionEventsCacheSize)
if err != nil {
return nil, err
}
executeParamsCache, err := lru.New[int, *trace.Event](executionEventsCacheSize)
if err != nil {
return nil, err
}
return &ExecFailedGenerator{
execEndInfo: executeProcsCache,
baseEvents: executeParamsCache,
deriveBase: makeDeriveBase(events.ProcessExecuteFailed),
baseEvents: executeParamsCache,
deriveBase: makeDeriveBase(events.ProcessExecuteFailed),
}, nil
}

Expand Down Expand Up @@ -78,7 +72,7 @@ func (gen *ExecFailedGenerator) deriveEvent(event *trace.Event) (
// handleExecFinished will add info on top of base event unless events came out of order. Sends an event in any case.
// Should be simplified once events reach from kernel-space to user-space are ordered!
func (gen *ExecFailedGenerator) handleExecFinished(event *trace.Event) (*trace.Event, error) {
defer gen.execEndInfo.Remove(event.HostProcessID)
defer gen.baseEvents.Remove(event.HostProcessID)
execInfo := execEndInfo{
returnCode: event.ReturnValue,
timestamp: event.Timestamp,
Expand Down
Loading