Skip to content
Open
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
11 changes: 10 additions & 1 deletion pkg/systemlogmonitor/logwatchers/journald/log_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,16 @@ func (j *journaldWatcher) watchLoop() {
}
// If next reaches the end, wait for waitLogTimeout.
if n == 0 {
j.journal.Wait(waitLogTimeout)
// sd_journal_wait can return immediately with a negative
// errno (e.g. -ENOSPC when inotify user instances are
// exhausted, so sd_journal_get_fd cannot create the
// inotify instance it needs). Fall back to a manual sleep
// so the loop honors waitLogTimeout instead of spinning
// at 100% CPU.
if r := j.journal.Wait(waitLogTimeout); r < 0 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this logs every ~5s for as long as the condition lasts (~720/hr). would it be better to log once when it fails and once when it recovers instead?

klog.Errorf("sd_journal_wait failed (%d), backing off for %v", r, waitLogTimeout)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It may be worth decoding the errno:

if r := j.journal.Wait(waitLogTimeout); r < 0 {
    klog.Errorf("sd_journal_wait failed (%d: %s), backing off for %v", r, syscall.Errno(-r), waitLogTimeout)
    ...
}

if we use syscall.Errno(-r), "no space left on device" is more descriptive than -28.

time.Sleep(waitLogTimeout)
}
continue
}

Expand Down