Skip to content

Commit c3fb0c6

Browse files
authored
Merge pull request #252 from coroot/journald_inotify_fallback
journald: add fallback when inotify is unavailable due to system limits
2 parents eab45e1 + ef0fc3e commit c3fb0c6

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

logs/journald_reader.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ import (
1111
"k8s.io/klog/v2"
1212
)
1313

14+
const (
15+
journaldPollTimeout = 100 * time.Millisecond
16+
)
17+
1418
type JournaldReader struct {
1519
journal *sdjournal.Journal
1620
subscribers map[string]chan<- logparser.LogEntry
@@ -60,7 +64,11 @@ func (r *JournaldReader) follow() {
6064
return
6165
}
6266
if c <= 0 {
63-
r.journal.Wait(time.Millisecond * 100)
67+
t := time.Now()
68+
ret := r.journal.Wait(journaldPollTimeout)
69+
if ret <= 0 && time.Since(t) < journaldPollTimeout { // inotify can't work due to system limits
70+
time.Sleep(journaldPollTimeout)
71+
}
6472
continue
6573
}
6674
e, err := r.journal.GetEntry()

0 commit comments

Comments
 (0)