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

Process monitor enhanced logs #21063

Merged
merged 2 commits into from
Nov 23, 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
7 changes: 7 additions & 0 deletions pkg/process/monitor/process_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ func (pm *ProcessMonitor) initCallbackRunner() {

// mainEventLoop is an event loop receiving events from netlink, or periodic events, and handles them.
func (pm *ProcessMonitor) mainEventLoop() {
log.Info("process monitor main event loop is starting")
logTicker := time.NewTicker(2 * time.Minute)

defer func() {
Expand All @@ -218,9 +219,11 @@ func (pm *ProcessMonitor) mainEventLoop() {
for {
select {
case <-pm.done:
log.Info("process monitor main event loop is shutting down, having been marked to stop")
return
case event, ok := <-pm.netlinkEventsChannel:
if !ok {
log.Info("process monitor main event loop is shutting down, netlink events channel was closed")
return
}

Expand Down Expand Up @@ -249,6 +252,7 @@ func (pm *ProcessMonitor) mainEventLoop() {
}
case _, ok := <-pm.netlinkErrorsChannel:
if !ok {
log.Info("process monitor main event loop is shutting down, netlink errors channel was closed")
return
}
pm.tel.restart.Add(1)
Expand Down Expand Up @@ -283,6 +287,7 @@ func (pm *ProcessMonitor) Initialize() error {
var initErr error
pm.initOnce.Do(
func() {
log.Info("initializing process monitor")
pm.tel = newProcessMonitorTelemetry()
pm.done = make(chan struct{})
pm.initCallbackRunner()
Expand Down Expand Up @@ -313,6 +318,7 @@ func (pm *ProcessMonitor) Initialize() error {
return nil
}
// Scanning already running processes
log.Info("process monitor init, scanning all processes")
if err := kernel.WithAllProcs(kernel.ProcFSRoot(), handleProcessExecWrapper); err != nil {
initErr = fmt.Errorf("process monitor init, scanning all process failed %s", err)
pm.tel.processScanFailed.Add(1)
Expand Down Expand Up @@ -369,6 +375,7 @@ func (pm *ProcessMonitor) Stop() {
}

// We can get here only once, if the refcount is zero.
log.Info("process monitor stopping due to a refcount of 0")
if pm.done != nil {
close(pm.done)
pm.processMonitorWG.Wait()
Expand Down