diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-03-18 09:22:07 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-18 09:22:07 -0700 |
commit | 4b3161b6870e9e96025a307c18bf1f5cb4473f1a (patch) | |
tree | 4f6512ae594ec9b475af29716afb9916428a7542 /libpod/container_log.go | |
parent | ea54a1c2f51d3173649277939738ce9b1c392076 (diff) | |
parent | 46f18764f205ead97fb5da70104951cf90bf5b6b (diff) | |
download | podman-4b3161b6870e9e96025a307c18bf1f5cb4473f1a.tar.gz podman-4b3161b6870e9e96025a307c18bf1f5cb4473f1a.tar.bz2 podman-4b3161b6870e9e96025a307c18bf1f5cb4473f1a.zip |
Merge pull request #2679 from baude/issue2677
podman logs on created container should exit
Diffstat (limited to 'libpod/container_log.go')
-rw-r--r-- | libpod/container_log.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/libpod/container_log.go b/libpod/container_log.go index 7964e4022..e998ad316 100644 --- a/libpod/container_log.go +++ b/libpod/container_log.go @@ -3,6 +3,7 @@ package libpod import ( "fmt" "io/ioutil" + "os" "strings" "sync" "time" @@ -54,6 +55,10 @@ func (r *Runtime) Log(containers []*Container, options *LogOptions, logChannel c func (c *Container) ReadLog(options *LogOptions, logChannel chan *LogLine) error { t, tailLog, err := getLogFile(c.LogPath(), options) if err != nil { + // If the log file does not exist, this is not fatal. + if os.IsNotExist(errors.Cause(err)) { + return nil + } return errors.Wrapf(err, "unable to read log file %s for %s ", c.ID(), c.LogPath()) } options.WaitGroup.Add(1) @@ -111,7 +116,7 @@ func getLogFile(path string, options *LogOptions) (*tail.Tail, []*LogLine, error Whence: whence, } - t, err := tail.TailFile(path, tail.Config{Poll: true, Follow: options.Follow, Location: &seek, Logger: tail.DiscardingLogger}) + t, err := tail.TailFile(path, tail.Config{MustExist: true, Poll: true, Follow: options.Follow, Location: &seek, Logger: tail.DiscardingLogger}) return t, logTail, err } |