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

ignore ebpf events with empty container name #163

Merged
merged 1 commit into from
Dec 21, 2023
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
34 changes: 22 additions & 12 deletions pkg/containerwatcher/v1/container_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ func CreateIGContainerWatcher(cfg config.Config, applicationProfileManager appli
// Create a capabilities worker pool
capabilitiesWorkerPool, err := ants.NewPoolWithFunc(capabilitiesWorkerPoolSize, func(i interface{}) {
event := i.(tracercapabilitiestype.Event)
// ignore events with empty container name
if event.K8s.ContainerName == "" {
return
}
k8sContainerID := utils.CreateK8sContainerID(event.K8s.Namespace, event.K8s.PodName, event.K8s.ContainerName)
applicationProfileManager.ReportCapability(k8sContainerID, event.CapName)
})
Expand All @@ -98,6 +102,10 @@ func CreateIGContainerWatcher(cfg config.Config, applicationProfileManager appli
// Create an exec worker pool
execWorkerPool, err := ants.NewPoolWithFunc(execWorkerPoolSize, func(i interface{}) {
event := i.(tracerexectype.Event)
// ignore events with empty container name
if event.K8s.ContainerName == "" {
return
}
k8sContainerID := utils.CreateK8sContainerID(event.K8s.Namespace, event.K8s.PodName, event.K8s.ContainerName)
path := event.Comm
if len(event.Args) > 0 {
Expand All @@ -109,10 +117,13 @@ func CreateIGContainerWatcher(cfg config.Config, applicationProfileManager appli
if err != nil {
return nil, fmt.Errorf("creating exec worker pool: %w", err)
}

// Create an open worker pool
openWorkerPool, err := ants.NewPoolWithFunc(openWorkerPoolSize, func(i interface{}) {
event := i.(traceropentype.Event)
// ignore events with empty container name
if event.K8s.ContainerName == "" {
return
}
k8sContainerID := utils.CreateK8sContainerID(event.K8s.Namespace, event.K8s.PodName, event.K8s.ContainerName)
path := event.Path
if cfg.EnableFullPathTracing {
Expand All @@ -124,33 +135,32 @@ func CreateIGContainerWatcher(cfg config.Config, applicationProfileManager appli
if err != nil {
return nil, fmt.Errorf("creating open worker pool: %w", err)
}

// Create a network worker pool
networkWorkerPool, err := ants.NewPoolWithFunc(networkWorkerPoolSize, func(i interface{}) {
event := i.(tracernetworktype.Event)

k8sContainerID := utils.CreateK8sContainerID(event.K8s.Namespace, event.K8s.PodName, event.K8s.ContainerName)

if k8sContainerID == "//" {
// ignore events with empty container name
if event.K8s.ContainerName == "" {
return
}

networkManagerClient.SaveNetworkEvent(event.Runtime.ContainerID, event.K8s.PodName, event)
})

if err != nil {
return nil, fmt.Errorf("creating network worker pool: %w", err)
}
// Create a dns worker pool
dnsWorkerPool, err := ants.NewPoolWithFunc(dnsWorkerPoolSize, func(i interface{}) {
event := i.(tracerdnstype.Event)

// ignore events with empty container name
if event.K8s.ContainerName == "" {
return
}
if event.Qr != tracerdnstype.DNSPktTypeResponse {
return
}

dnsManagerClient.ProcessDNSEvent(event)
})

if err != nil {
return nil, fmt.Errorf("creating open network pool: %w", err)
return nil, fmt.Errorf("creating dns worker pool: %w", err)
}

return &IGContainerWatcher{
Expand Down
Loading