runtime: do not check for EOF error in console watcher

The documentation of the bufio package explicitly says

"Err returns the first non-EOF error that was encountered by the
Scanner."

When io.EOF happens, `Err()` will return `nil` and `Scan()` will return
`false`.

Fixes #4079

Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
This commit is contained in:
Rafael Fonseca 2022-05-17 15:08:36 +02:00
parent 5d43718494
commit 8052fe62fa

View File

@ -1037,15 +1037,13 @@ func (cw *consoleWatcher) start(s *Sandbox) (err error) {
}
if err := scanner.Err(); err != nil {
if err == io.EOF {
s.Logger().Info("console watcher quits")
} else {
s.Logger().WithError(err).WithFields(logrus.Fields{
"console-protocol": cw.proto,
"console-url": cw.consoleURL,
"sandbox": s.id,
}).Error("Failed to read guest console logs")
}
s.Logger().WithError(err).WithFields(logrus.Fields{
"console-protocol": cw.proto,
"console-url": cw.consoleURL,
"sandbox": s.id,
}).Error("Failed to read guest console logs")
} else { // The error is `nil` in case of io.EOF
s.Logger().Info("console watcher quits")
}
}()