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
parent 5ee2c2a647
commit f65647463e
1 changed files with 5 additions and 2 deletions

View File

@ -1,6 +1,7 @@
package libcontainerd
import (
"fmt"
"io"
"strings"
"syscall"
@ -105,8 +106,10 @@ func (ctr *container) start() error {
exitCode := ctr.waitProcessExitCode(&ctr.process)
if exitCode != 0 {
logrus.Warnf("libcontainerd: servicing container %s returned non-zero exit code %d", ctr.containerID, exitCode)
return ctr.terminate()
if err := ctr.terminate(); err != nil {
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)