mirror of https://github.com/docker/docs.git
Fixing Windows update logic.
Removing the call to Shutdown from within Signal in order to rely on waitExit handling the exit of the process. Signed-off-by: Stefan J. Wernli <swernli@microsoft.com>
This commit is contained in:
parent
cf783266ff
commit
a5b64f2847
|
@ -54,10 +54,7 @@ func (daemon *Daemon) StateChanged(id string, e libcontainerd.StateInfo) error {
|
||||||
"exitCode": strconv.Itoa(int(e.ExitCode)),
|
"exitCode": strconv.Itoa(int(e.ExitCode)),
|
||||||
}
|
}
|
||||||
daemon.LogContainerEventWithAttributes(c, "die", attributes)
|
daemon.LogContainerEventWithAttributes(c, "die", attributes)
|
||||||
if err := c.ToDisk(); err != nil {
|
return c.ToDisk()
|
||||||
return err
|
|
||||||
}
|
|
||||||
return daemon.postRunProcessing(c, e)
|
|
||||||
case libcontainerd.StateExitProcess:
|
case libcontainerd.StateExitProcess:
|
||||||
c.Lock()
|
c.Lock()
|
||||||
defer c.Unlock()
|
defer c.Unlock()
|
||||||
|
|
|
@ -344,6 +344,8 @@ func (clnt *client) Signal(containerID string, sig int) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cont.manualStopRequested = true
|
||||||
|
|
||||||
logrus.Debugf("lcd: Signal() containerID=%s sig=%d pid=%d", containerID, sig, cont.systemPid)
|
logrus.Debugf("lcd: Signal() containerID=%s sig=%d pid=%d", containerID, sig, cont.systemPid)
|
||||||
context := fmt.Sprintf("Signal: sig=%d pid=%d", sig, cont.systemPid)
|
context := fmt.Sprintf("Signal: sig=%d pid=%d", sig, cont.systemPid)
|
||||||
|
|
||||||
|
@ -352,7 +354,6 @@ func (clnt *client) Signal(containerID string, sig int) error {
|
||||||
if err := hcsshim.TerminateComputeSystem(containerID, hcsshim.TimeoutInfinite, context); err != nil {
|
if err := hcsshim.TerminateComputeSystem(containerID, hcsshim.TimeoutInfinite, context); err != nil {
|
||||||
logrus.Errorf("Failed to terminate %s - %q", containerID, err)
|
logrus.Errorf("Failed to terminate %s - %q", containerID, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Terminate Process
|
// Terminate Process
|
||||||
if err = hcsshim.TerminateProcessInComputeSystem(containerID, cont.systemPid); err != nil {
|
if err = hcsshim.TerminateProcessInComputeSystem(containerID, cont.systemPid); err != nil {
|
||||||
|
@ -360,24 +361,8 @@ func (clnt *client) Signal(containerID string, sig int) error {
|
||||||
// Ignore errors
|
// Ignore errors
|
||||||
err = nil
|
err = nil
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Shutdown the compute system
|
|
||||||
const shutdownTimeout = 5 * 60 * 1000 // 5 minutes
|
|
||||||
if err := hcsshim.ShutdownComputeSystem(containerID, shutdownTimeout, context); err != nil {
|
|
||||||
if herr, ok := err.(*hcsshim.HcsError); !ok ||
|
|
||||||
(herr.Err != hcsshim.ERROR_SHUTDOWN_IN_PROGRESS &&
|
|
||||||
herr.Err != ErrorBadPathname &&
|
|
||||||
herr.Err != syscall.ERROR_PATH_NOT_FOUND) {
|
|
||||||
logrus.Debugf("signal - error from ShutdownComputeSystem %v on %s. Calling TerminateComputeSystem", err, containerID)
|
|
||||||
if err := hcsshim.TerminateComputeSystem(containerID, shutdownTimeout, "signal"); err != nil {
|
|
||||||
logrus.Debugf("signal - ignoring error from TerminateComputeSystem on %s %v", containerID, err)
|
|
||||||
} else {
|
|
||||||
logrus.Debugf("Successful TerminateComputeSystem after failed ShutdownComputeSystem on %s during signal %v", containerID, sig)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logrus.Errorf("Failed to shutdown %s - %q", containerID, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,8 @@ type container struct {
|
||||||
// but can be called from the RestartManager context which does not
|
// but can be called from the RestartManager context which does not
|
||||||
// otherwise have access to the Spec
|
// otherwise have access to the Spec
|
||||||
ociSpec Spec
|
ociSpec Spec
|
||||||
|
|
||||||
|
manualStopRequested bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ctr *container) newProcess(friendlyName string) *process {
|
func (ctr *container) newProcess(friendlyName string) *process {
|
||||||
|
@ -163,11 +165,10 @@ func (ctr *container) waitExit(pid uint32, processFriendlyName string, isFirstPr
|
||||||
// But it could have been an exec'd process which exited
|
// But it could have been an exec'd process which exited
|
||||||
if !isFirstProcessToStart {
|
if !isFirstProcessToStart {
|
||||||
si.State = StateExitProcess
|
si.State = StateExitProcess
|
||||||
}
|
} else {
|
||||||
|
// Since this is the init process, always call into vmcompute.dll to
|
||||||
// If this is the init process, always call into vmcompute.dll to
|
|
||||||
// shutdown the container after we have completed.
|
// shutdown the container after we have completed.
|
||||||
if isFirstProcessToStart {
|
|
||||||
propertyCheckFlag := 1 // Include update pending check.
|
propertyCheckFlag := 1 // Include update pending check.
|
||||||
csProperties, err := hcsshim.GetComputeSystemProperties(ctr.containerID, uint32(propertyCheckFlag))
|
csProperties, err := hcsshim.GetComputeSystemProperties(ctr.containerID, uint32(propertyCheckFlag))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -196,7 +197,7 @@ func (ctr *container) waitExit(pid uint32, processFriendlyName string, isFirstPr
|
||||||
logrus.Debugf("Completed shutting down container %s", ctr.containerID)
|
logrus.Debugf("Completed shutting down container %s", ctr.containerID)
|
||||||
}
|
}
|
||||||
|
|
||||||
if si.State == StateExit && ctr.restartManager != nil {
|
if !ctr.manualStopRequested && ctr.restartManager != nil {
|
||||||
restart, wait, err := ctr.restartManager.ShouldRestart(uint32(exitCode), false, time.Since(ctr.startedAt))
|
restart, wait, err := ctr.restartManager.ShouldRestart(uint32(exitCode), false, time.Since(ctr.startedAt))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Error(err)
|
logrus.Error(err)
|
||||||
|
|
Loading…
Reference in New Issue