Fixing error reporting on servicing failure

The code that handles waiting for the servicing container to complete correctly grabs the exit code and logs a failure, but doesn't return that failure to the caller, mistakenly causing servicing operations to look successful when they really failed during processing.

Signed-off-by: Stefan J. Wernli <swernli@microsoft.com>
This commit is contained in:
Stefan J. Wernli 2016-10-11 17:11:56 -07:00
Родитель 5ee2c2a647
Коммит f65647463e
1 изменённых файлов: 5 добавлений и 2 удалений

Просмотреть файл

@ -1,6 +1,7 @@
package libcontainerd package libcontainerd
import ( import (
"fmt"
"io" "io"
"strings" "strings"
"syscall" "syscall"
@ -105,8 +106,10 @@ func (ctr *container) start() error {
exitCode := ctr.waitProcessExitCode(&ctr.process) exitCode := ctr.waitProcessExitCode(&ctr.process)
if exitCode != 0 { if exitCode != 0 {
logrus.Warnf("libcontainerd: servicing container %s returned non-zero exit code %d", ctr.containerID, exitCode) if err := ctr.terminate(); err != nil {
return ctr.terminate() logrus.Warnf("libcontainerd: terminating servicing container %s failed: %s", ctr.containerID, err)
}
return fmt.Errorf("libcontainerd: servicing container %s returned non-zero exit code %d", ctr.containerID, exitCode)
} }
return ctr.hcsContainer.WaitTimeout(time.Minute * 5) return ctr.hcsContainer.WaitTimeout(time.Minute * 5)