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

Adding a check if the container is still being monitord before readin… #306

Merged
merged 4 commits into from
Jun 5, 2024
Merged
Changes from 1 commit
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
10 changes: 5 additions & 5 deletions pkg/containerwatcher/v1/container_watcher_private.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (ch *IGContainerWatcher) containerCallback(notif containercollection.PubSub
ch.timeBasedContainers.Add(notif.Container.Runtime.ContainerID)
}

tracingContext := context.Background()
tracingContext := make(chan struct{})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe a better name?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would you call it?


switch notif.Type {
case containercollection.EventTypeAddContainer:
Expand All @@ -47,8 +47,8 @@ func (ch *IGContainerWatcher) containerCallback(notif containercollection.PubSub
go func() {
for {
select {
case <-tracingContext.Done():
logger.L().Info("stop monitor on container - container has terminated",
case <-tracingContext:
logger.L().Info("stop traceloop on container - container has terminated",
helpers.String("container ID", notif.Container.Runtime.ContainerID),
helpers.String("k8s workload", k8sContainerID))
return
Expand All @@ -64,7 +64,7 @@ func (ch *IGContainerWatcher) containerCallback(notif containercollection.PubSub
}

// Sleep for a while before reading the next batch of events.
time.Sleep(2 * time.Second) // TODO: make this configurable.
time.Sleep(5 * time.Second) // TODO: make this configurable.
}
}
}()
Expand All @@ -83,7 +83,7 @@ func (ch *IGContainerWatcher) containerCallback(notif containercollection.PubSub
logger.L().Info("stop monitor on container - container has terminated",
helpers.String("container ID", notif.Container.Runtime.ContainerID),
helpers.String("k8s workload", k8sContainerID))
tracingContext.Done()
close(tracingContext)
ch.preRunningContainersIDs.Remove(notif.Container.Runtime.ContainerID)
ch.timeBasedContainers.Remove(notif.Container.Runtime.ContainerID)
ch.syscallTracer.Detach(notif.Container.Mntns)
Expand Down
Loading