From 61e4e69be5fa765345bd11ec07c89de0b3aba0f9 Mon Sep 17 00:00:00 2001 From: Bhargavi Gudi Date: Tue, 6 Jan 2026 22:24:07 +0530 Subject: [PATCH] OCPBUGS-62730 - update jsonenricher.go resolved format issue Updated proper synchronization for the LogBucket Resolved go-lint issues revert nodeNameCopy := nodeName --- internal/pkg/daemon/enricher/jsonenricher.go | 16 ++++++++++++++-- internal/pkg/daemon/enricher/types/types.go | 1 + 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/internal/pkg/daemon/enricher/jsonenricher.go b/internal/pkg/daemon/enricher/jsonenricher.go index fd690fd218..e4a4fdb016 100644 --- a/internal/pkg/daemon/enricher/jsonenricher.go +++ b/internal/pkg/daemon/enricher/jsonenricher.go @@ -320,14 +320,20 @@ func (e *JsonEnricher) Run(ctx context.Context, runErr chan<- error) { "unable to get uid and gid", "line", line) } - logBucket.ProcessInfo = e.fetchProcessInfo(auditLine.ProcessID, + pi := e.fetchProcessInfo(auditLine.ProcessID, auditLine.Executable, uid, gid) + logBucket.Mu.Lock() + logBucket.ProcessInfo = pi + logBucket.Mu.Unlock() } e.processEbpf(logBucket, auditLine) if logBucket.ContainerInfo == nil { - logBucket.ContainerInfo = e.fetchContainerInfo(ctx, auditLine.ProcessID, nodeName) + ci := e.fetchContainerInfo(ctx, auditLine.ProcessID, nodeName) + logBucket.Mu.Lock() + logBucket.ContainerInfo = ci + logBucket.Mu.Unlock() } logBucket.SyscallIds.LoadOrStore(auditLine.SystemCallID, struct{}{}) @@ -341,6 +347,9 @@ func (e *JsonEnricher) Run(ctx context.Context, runErr chan<- error) { } func (e *JsonEnricher) processEbpf(logBucket *types.LogBucket, auditLine *types.AuditLine) { + logBucket.Mu.Lock() + defer logBucket.Mu.Unlock() + if e.bpfProcessCache != nil && logBucket.ProcessInfo != nil && logBucket.ProcessInfo.CmdLine == "" { cmdLine, errCmdLine := e.bpfProcessCache.GetCmdLine(auditLine.ProcessID) if errCmdLine == nil { @@ -435,6 +444,9 @@ func (e *JsonEnricher) dispatchSeccompLine( return true }) + logBucket.Mu.RLock() + defer logBucket.Mu.RUnlock() + var resource map[string]string if logBucket.ProcessInfo == nil { diff --git a/internal/pkg/daemon/enricher/types/types.go b/internal/pkg/daemon/enricher/types/types.go index 36c59f8012..eb9f861fc3 100644 --- a/internal/pkg/daemon/enricher/types/types.go +++ b/internal/pkg/daemon/enricher/types/types.go @@ -72,6 +72,7 @@ type ProcessInfo struct { ExecRequestId *string } type LogBucket struct { + Mu sync.RWMutex SyscallIds sync.Map ContainerInfo *ContainerInfo ProcessInfo *ProcessInfo