aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2018-03-01 17:38:22 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-03-01 23:25:41 +0000
commit546463964e8de7c82f976c9b1808b9867504b4ef (patch)
treee36153975d0ffa7f39ab3395b49eb866cae93cf1
parentc5dc7f81fc5a1078b0bc66bd9e7a1f23a03242c5 (diff)
downloadpodman-546463964e8de7c82f976c9b1808b9867504b4ef.tar.gz
podman-546463964e8de7c82f976c9b1808b9867504b4ef.tar.bz2
podman-546463964e8de7c82f976c9b1808b9867504b4ef.zip
Fix issue with podman logs on fresh containers
Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #434 Approved by: baude
-rw-r--r--cmd/podman/logs.go20
1 files changed, 19 insertions, 1 deletions
diff --git a/cmd/podman/logs.go b/cmd/podman/logs.go
index 5551d6157..07d95aaf8 100644
--- a/cmd/podman/logs.go
+++ b/cmd/podman/logs.go
@@ -10,6 +10,7 @@ import (
"bufio"
"github.com/pkg/errors"
"github.com/projectatomic/libpod/libpod"
+ "github.com/sirupsen/logrus"
"github.com/urfave/cli"
)
@@ -104,7 +105,24 @@ func logsCmd(c *cli.Context) error {
return err
}
- file, err := os.Open(ctr.LogPath())
+ logPath := ctr.LogPath()
+
+ state, err := ctr.State()
+ if err != nil {
+ return err
+ }
+
+ // If the log file does not exist yet and the container is in the
+ // Configured state, it has never been started before and no logs exist
+ // Exit cleanly in this case
+ if _, err := os.Stat(logPath); err != nil {
+ if state == libpod.ContainerStateConfigured {
+ logrus.Debugf("Container has not been created, no logs exist yet")
+ return nil
+ }
+ }
+
+ file, err := os.Open(logPath)
if err != nil {
return errors.Wrapf(err, "unable to read container log file")
}