From 2e21f513756b4950ac203a0612b1d4c4071ea8a3 Mon Sep 17 00:00:00 2001 From: Dan Mihai Date: Wed, 15 Jan 2025 00:22:56 +0000 Subject: [PATCH] runtime: skip empty Guest console output lines Skip logging empty lines of text from the Guest console output, if there are any such lines. Without this change, the Guest console log from CLH + /dev/pts/0 has twice as many lines of text. Half of these lines are empty. Fixes: #10737 Signed-off-by: Dan Mihai --- src/runtime/virtcontainers/sandbox.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/runtime/virtcontainers/sandbox.go b/src/runtime/virtcontainers/sandbox.go index 33244bc53..3711da7f5 100644 --- a/src/runtime/virtcontainers/sandbox.go +++ b/src/runtime/virtcontainers/sandbox.go @@ -1275,12 +1275,15 @@ func (cw *consoleWatcher) start(s *Sandbox) (err error) { go func() { for scanner.Scan() { - s.Logger().WithFields(logrus.Fields{ - "console-protocol": cw.proto, - "console-url": cw.consoleURL, - "sandbox": s.id, - "vmconsole": scanner.Text(), - }).Debug("reading guest console") + text := scanner.Text() + if text != "" { + s.Logger().WithFields(logrus.Fields{ + "console-protocol": cw.proto, + "console-url": cw.consoleURL, + "sandbox": s.id, + "vmconsole": text, + }).Debug("reading guest console") + } } if err := scanner.Err(); err != nil {