From 3e00e0cd712d3bc88b76e06ff2be1f3a75b10e8b Mon Sep 17 00:00:00 2001 From: Euan Kemp Date: Fri, 13 May 2016 13:25:36 -0700 Subject: [PATCH] rkt: Don't warn on empty pod logs If a pod has not printed anything to stdout/stderr, it's expected behaviour to get `-- No entries --`, even when requesting json output. Prior to this change, a warning would be printed in such an occasion. --- pkg/kubelet/rkt/log.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/kubelet/rkt/log.go b/pkg/kubelet/rkt/log.go index cad61bce4d7..738b4ea45a7 100644 --- a/pkg/kubelet/rkt/log.go +++ b/pkg/kubelet/rkt/log.go @@ -18,6 +18,7 @@ package rkt import ( "bufio" + "bytes" "encoding/json" "fmt" "io" @@ -40,6 +41,8 @@ const ( journalSinceLayout = "2006-01-02 15:04:05" ) +var journalNoEntriesLine = []byte(`"-- No entries --"`) + // pipeLog reads and parses the journal json object from r, // and writes the logs line by line to w. func pipeLog(wg *sync.WaitGroup, logOptions *api.PodLogOptions, r io.ReadCloser, w io.Writer) { @@ -52,9 +55,12 @@ func pipeLog(wg *sync.WaitGroup, logOptions *api.PodLogOptions, r io.ReadCloser, for scanner.Scan() { var data interface{} b := scanner.Bytes() + if bytes.Equal(b, journalNoEntriesLine) { + continue + } if err := json.Unmarshal(b, &data); err != nil { - glog.Warningf("rkt: Cannot unmarshal journal log, skipping line: %v", err) + glog.Warningf("rkt: Cannot unmarshal journal log %q, skipping line: %v", string(b), err) continue } @@ -142,6 +148,7 @@ func (r *Runtime) GetContainerLogs(pod *api.Pod, containerID kubecontainer.Conta } } + glog.V(4).Infof("rkt: gettings logs with command %q", cmd.Args) outPipe, err := cmd.StdoutPipe() if err != nil { glog.Errorf("rkt: cannot create pipe for journalctl's stdout: %v", err)