aboutsummaryrefslogtreecommitdiff
path: root/libpod/container_log.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2020-06-10 14:35:00 -0400
committerMatthew Heon <mheon@redhat.com>2020-06-17 11:11:46 -0400
commit0e171b7b3327948f2e9e32d9e496736bd7a48009 (patch)
treec52bdf719ac4fb248cf19662b1fa41c2472e4aec /libpod/container_log.go
parent38391ed25fdb1cc53b70a75ee4fbe7ea0fa782c3 (diff)
downloadpodman-0e171b7b3327948f2e9e32d9e496736bd7a48009.tar.gz
podman-0e171b7b3327948f2e9e32d9e496736bd7a48009.tar.bz2
podman-0e171b7b3327948f2e9e32d9e496736bd7a48009.zip
Do not share container log driver for exec
When the container uses journald logging, we don't want to automatically use the same driver for its exec sessions. If we do we will pollute the journal (particularly in the case of healthchecks) with large amounts of undesired logs. Instead, force exec sessions logs to file for now; we can add a log-driver flag later (we'll probably want to add a `podman logs` command that reads exec session logs at the same time). As part of this, add support for the new 'none' logs driver in Conmon. It will be the default log driver for exec sessions, and can be optionally selected for containers. Great thanks to Joe Gooch (mrwizard@dok.org) for adding support to Conmon for a null log driver, and wiring it in here. Fixes #6555 Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'libpod/container_log.go')
-rw-r--r--libpod/container_log.go17
1 files changed, 13 insertions, 4 deletions
diff --git a/libpod/container_log.go b/libpod/container_log.go
index 39c395fe6..ac4720cfb 100644
--- a/libpod/container_log.go
+++ b/libpod/container_log.go
@@ -22,12 +22,21 @@ func (r *Runtime) Log(containers []*Container, options *logs.LogOptions, logChan
// ReadLog reads a containers log based on the input options and returns loglines over a channel.
func (c *Container) ReadLog(options *logs.LogOptions, logChannel chan *logs.LogLine) error {
- // TODO Skip sending logs until journald logs can be read
- // TODO make this not a magic string
- if c.LogDriver() == define.JournaldLogging {
+ switch c.LogDriver() {
+ case define.NoLogging:
+ return errors.Wrapf(define.ErrNoLogs, "this container is using the 'none' log driver, cannot read logs")
+ case define.JournaldLogging:
+ // TODO Skip sending logs until journald logs can be read
return c.readFromJournal(options, logChannel)
+ case define.JSONLogging:
+ // TODO provide a separate implementation of this when Conmon
+ // has support.
+ fallthrough
+ case define.KubernetesLogging, "":
+ return c.readFromLogFile(options, logChannel)
+ default:
+ return errors.Wrapf(define.ErrInternal, "unrecognized log driver %q, cannot read logs", c.LogDriver())
}
- return c.readFromLogFile(options, logChannel)
}
func (c *Container) readFromLogFile(options *logs.LogOptions, logChannel chan *logs.LogLine) error {