aboutsummaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-11-15 22:09:29 +0100
committerGitHub <noreply@github.com>2021-11-15 22:09:29 +0100
commit45d28c2219b64d81323b7a15fef589b11b6c63b3 (patch)
tree8a98c2c087fc7d8719cda00ad81f181ab93cdc19 /libpod
parent230f0b622e391b78626f150471fce5c198048ed8 (diff)
parent63ef7135d957d396b87727b6151f9caf3266366d (diff)
downloadpodman-45d28c2219b64d81323b7a15fef589b11b6c63b3.tar.gz
podman-45d28c2219b64d81323b7a15fef589b11b6c63b3.tar.bz2
podman-45d28c2219b64d81323b7a15fef589b11b6c63b3.zip
Merge pull request #12285 from nalind/journal-follow-not-early
journald logs: keep reading until the journal's end
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container_log_linux.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/libpod/container_log_linux.go b/libpod/container_log_linux.go
index 324aa3b98..d3d7c8397 100644
--- a/libpod/container_log_linux.go
+++ b/libpod/container_log_linux.go
@@ -37,9 +37,11 @@ func (c *Container) initializeJournal(ctx context.Context) error {
m := make(map[string]string)
m["SYSLOG_IDENTIFIER"] = "podman"
m["PODMAN_ID"] = c.ID()
- m["CONTAINER_ID_FULL"] = c.ID()
history := events.History
m["PODMAN_EVENT"] = history.String()
+ container := events.Container
+ m["PODMAN_TYPE"] = container.String()
+ m["PODMAN_TIME"] = time.Now().Format(time.RFC3339Nano)
return journal.Send("", journal.PriInfo, m)
}
@@ -95,6 +97,7 @@ func (c *Container) readFromJournal(ctx context.Context, options *logs.LogOption
// exponential backoff.
var cursor string
var cursorError error
+ var containerCouldBeLogging bool
for i := 1; i <= 3; i++ {
cursor, cursorError = journal.GetCursor()
hundreds := 1
@@ -172,7 +175,7 @@ func (c *Container) readFromJournal(ctx context.Context, options *logs.LogOption
doTailFunc()
}
// Unless we follow, quit.
- if !options.Follow {
+ if !options.Follow || !containerCouldBeLogging {
return
}
// Sleep until something's happening on the journal.
@@ -201,11 +204,14 @@ func (c *Container) readFromJournal(ctx context.Context, options *logs.LogOption
logrus.Errorf("Failed to translate event: %v", err)
return
}
- if status == events.Exited {
+ switch status {
+ case events.History, events.Init, events.Start, events.Restart:
+ containerCouldBeLogging = true
+ case events.Exited:
+ containerCouldBeLogging = false
if doTail {
doTailFunc()
}
- return
}
continue
}