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

journald logs: drain 1 more time at container exit #291

Closed
Closed
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 daemon/logger/journald/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,13 @@ func (s *journald) followJournal(logWatcher *logger.LogWatcher, config logger.Re
errstr := C.GoString(cerrstr)
fmtstr := "error %q while attempting to follow journal for container %q"
logrus.Errorf(fmtstr, errstr, s.vars["CONTAINER_ID_FULL"])
} else {
// In the event that we were told to stop (logWatcher.WatchClose() below), it's possible
// there's more data in the journal for this container that was written just as the container
// exited. Try to drain the journal one more time to pick up any last-minute journal entries.
// Note, this isn't fool-proof and there's no guarantee that we'll get all the trailing
// entries, but this is better than nothing, as it does yield entries more often than not.
s.drainJournal(logWatcher, config, j, cursor)
}
// Clean up.
C.close(pfd[0])
Expand Down