mirror of https://github.com/docker/docs.git
Adding postRunProcessing infrastructure for hanlding Windows Update.
Signed-off-by: Stefan J. Wernli <swernli@microsoft.com>
This commit is contained in:
parent
8eb8a1d6b8
commit
818a5198e4
|
@ -40,7 +40,10 @@ func (daemon *Daemon) StateChanged(id string, e libcontainerd.StateInfo) error {
|
||||||
// FIXME: here is race condition between two RUN instructions in Dockerfile
|
// FIXME: here is race condition between two RUN instructions in Dockerfile
|
||||||
// because they share same runconfig and change image. Must be fixed
|
// because they share same runconfig and change image. Must be fixed
|
||||||
// in builder/builder.go
|
// in builder/builder.go
|
||||||
return c.ToDisk()
|
if err := c.ToDisk(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return daemon.postRunProcessing(c, e)
|
||||||
case libcontainerd.StateRestart:
|
case libcontainerd.StateRestart:
|
||||||
c.Lock()
|
c.Lock()
|
||||||
defer c.Unlock()
|
defer c.Unlock()
|
||||||
|
@ -51,7 +54,10 @@ 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)
|
||||||
return c.ToDisk()
|
if err := c.ToDisk(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return daemon.postRunProcessing(c, e)
|
||||||
case libcontainerd.StateExitProcess:
|
case libcontainerd.StateExitProcess:
|
||||||
c.Lock()
|
c.Lock()
|
||||||
defer c.Unlock()
|
defer c.Unlock()
|
||||||
|
|
|
@ -12,3 +12,8 @@ func platformConstructExitStatus(e libcontainerd.StateInfo) *container.ExitStatu
|
||||||
OOMKilled: e.OOMKilled,
|
OOMKilled: e.OOMKilled,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// postRunProcessing perfoms any processing needed on the container after it has stopped.
|
||||||
|
func (daemon *Daemon) postRunProcessing(container *container.Container, e libcontainerd.StateInfo) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package daemon
|
package daemon
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/docker/docker/container"
|
"github.com/docker/docker/container"
|
||||||
"github.com/docker/docker/libcontainerd"
|
"github.com/docker/docker/libcontainerd"
|
||||||
)
|
)
|
||||||
|
@ -11,3 +13,12 @@ func platformConstructExitStatus(e libcontainerd.StateInfo) *container.ExitStatu
|
||||||
ExitCode: int(e.ExitCode),
|
ExitCode: int(e.ExitCode),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// postRunProcessing perfoms any processing needed on the container after it has stopped.
|
||||||
|
func (daemon *Daemon) postRunProcessing(container *container.Container, e libcontainerd.StateInfo) error {
|
||||||
|
//TODO Windows - handle update processing here...
|
||||||
|
if e.UpdatePending {
|
||||||
|
return fmt.Errorf("Windows: Update handling not implemented.")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
|
@ -269,9 +269,10 @@ func (clnt *client) setExited(containerID string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
err := clnt.backend.StateChanged(containerID, StateInfo{
|
err := clnt.backend.StateChanged(containerID, StateInfo{
|
||||||
|
CommonStateInfo: CommonStateInfo{
|
||||||
State: StateExit,
|
State: StateExit,
|
||||||
ExitCode: exitCode,
|
ExitCode: exitCode,
|
||||||
})
|
}})
|
||||||
|
|
||||||
// Unmount and delete the bundle folder
|
// Unmount and delete the bundle folder
|
||||||
if mts, err := mount.GetMounts(); err == nil {
|
if mts, err := mount.GetMounts(); err == nil {
|
||||||
|
|
|
@ -48,9 +48,10 @@ func (clnt *client) restore(cont *containerd.Container, options ...CreateOption)
|
||||||
clnt.appendContainer(container)
|
clnt.appendContainer(container)
|
||||||
|
|
||||||
err = clnt.backend.StateChanged(containerID, StateInfo{
|
err = clnt.backend.StateChanged(containerID, StateInfo{
|
||||||
|
CommonStateInfo: CommonStateInfo{
|
||||||
State: StateRestore,
|
State: StateRestore,
|
||||||
Pid: container.systemPid,
|
Pid: container.systemPid,
|
||||||
})
|
}})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -60,9 +61,10 @@ func (clnt *client) restore(cont *containerd.Container, options ...CreateOption)
|
||||||
// This should only be a pause or resume event
|
// This should only be a pause or resume event
|
||||||
if event.Type == StatePause || event.Type == StateResume {
|
if event.Type == StatePause || event.Type == StateResume {
|
||||||
return clnt.backend.StateChanged(containerID, StateInfo{
|
return clnt.backend.StateChanged(containerID, StateInfo{
|
||||||
|
CommonStateInfo: CommonStateInfo{
|
||||||
State: event.Type,
|
State: event.Type,
|
||||||
Pid: container.systemPid,
|
Pid: container.systemPid,
|
||||||
})
|
}})
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Warnf("unexpected backlog event: %#v", event)
|
logrus.Warnf("unexpected backlog event: %#v", event)
|
||||||
|
|
|
@ -505,9 +505,10 @@ func (clnt *client) Restore(containerID string, unusedOnWindows ...CreateOption)
|
||||||
// TODO Windows: Implement this. For now, just tell the backend the container exited.
|
// TODO Windows: Implement this. For now, just tell the backend the container exited.
|
||||||
logrus.Debugf("lcd Restore %s", containerID)
|
logrus.Debugf("lcd Restore %s", containerID)
|
||||||
return clnt.backend.StateChanged(containerID, StateInfo{
|
return clnt.backend.StateChanged(containerID, StateInfo{
|
||||||
|
CommonStateInfo: CommonStateInfo{
|
||||||
State: StateExit,
|
State: StateExit,
|
||||||
ExitCode: 1 << 31,
|
ExitCode: 1 << 31,
|
||||||
})
|
}})
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPidsForContainer returns a list of process IDs running in a container.
|
// GetPidsForContainer returns a list of process IDs running in a container.
|
||||||
|
|
|
@ -81,9 +81,10 @@ func (ctr *container) start() error {
|
||||||
ctr.systemPid = systemPid(resp.Container)
|
ctr.systemPid = systemPid(resp.Container)
|
||||||
|
|
||||||
return ctr.client.backend.StateChanged(ctr.containerID, StateInfo{
|
return ctr.client.backend.StateChanged(ctr.containerID, StateInfo{
|
||||||
|
CommonStateInfo: CommonStateInfo{
|
||||||
State: StateStart,
|
State: StateStart,
|
||||||
Pid: ctr.systemPid,
|
Pid: ctr.systemPid,
|
||||||
})
|
}})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ctr *container) newProcess(friendlyName string) *process {
|
func (ctr *container) newProcess(friendlyName string) *process {
|
||||||
|
@ -103,8 +104,10 @@ func (ctr *container) handleEvent(e *containerd.Event) error {
|
||||||
switch e.Type {
|
switch e.Type {
|
||||||
case StateExit, StatePause, StateResume, StateOOM:
|
case StateExit, StatePause, StateResume, StateOOM:
|
||||||
st := StateInfo{
|
st := StateInfo{
|
||||||
|
CommonStateInfo: CommonStateInfo{
|
||||||
State: e.Type,
|
State: e.Type,
|
||||||
ExitCode: e.Status,
|
ExitCode: e.Status,
|
||||||
|
},
|
||||||
OOMKilled: e.Type == StateExit && ctr.oom,
|
OOMKilled: e.Type == StateExit && ctr.oom,
|
||||||
}
|
}
|
||||||
if e.Type == StateOOM {
|
if e.Type == StateOOM {
|
||||||
|
|
|
@ -103,9 +103,10 @@ func (ctr *container) start() error {
|
||||||
|
|
||||||
// Tell the docker engine that the container has started.
|
// Tell the docker engine that the container has started.
|
||||||
si := StateInfo{
|
si := StateInfo{
|
||||||
|
CommonStateInfo: CommonStateInfo{
|
||||||
State: StateStart,
|
State: StateStart,
|
||||||
Pid: ctr.systemPid, // Not sure this is needed? Double-check monitor.go in daemon BUGBUG @jhowardmsft
|
Pid: ctr.systemPid, // Not sure this is needed? Double-check monitor.go in daemon BUGBUG @jhowardmsft
|
||||||
}
|
}}
|
||||||
return ctr.client.backend.StateChanged(ctr.containerID, si)
|
return ctr.client.backend.StateChanged(ctr.containerID, si)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -129,10 +130,13 @@ func (ctr *container) waitExit(pid uint32, processFriendlyName string, isFirstPr
|
||||||
|
|
||||||
// Assume the container has exited
|
// Assume the container has exited
|
||||||
si := StateInfo{
|
si := StateInfo{
|
||||||
|
CommonStateInfo: CommonStateInfo{
|
||||||
State: StateExit,
|
State: StateExit,
|
||||||
ExitCode: uint32(exitCode),
|
ExitCode: uint32(exitCode),
|
||||||
Pid: pid,
|
Pid: pid,
|
||||||
ProcessID: processFriendlyName,
|
ProcessID: processFriendlyName,
|
||||||
|
},
|
||||||
|
UpdatePending: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
// But it could have been an exec'd process which exited
|
// But it could have been an exec'd process which exited
|
||||||
|
@ -143,6 +147,11 @@ func (ctr *container) waitExit(pid uint32, processFriendlyName string, isFirstPr
|
||||||
// If 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 {
|
if isFirstProcessToStart {
|
||||||
|
|
||||||
|
// TODO Windows - add call into hcsshim to check if an update
|
||||||
|
// is pending once that is available.
|
||||||
|
//si.UpdatePending = CHECK IF UPDATE NEEDED
|
||||||
|
|
||||||
logrus.Debugf("Shutting down container %s", ctr.containerID)
|
logrus.Debugf("Shutting down container %s", ctr.containerID)
|
||||||
// Explicit timeout here rather than hcsshim.TimeoutInfinte to avoid a
|
// Explicit timeout here rather than hcsshim.TimeoutInfinte to avoid a
|
||||||
// (remote) possibility that ShutdownComputeSystem hangs indefinitely.
|
// (remote) possibility that ShutdownComputeSystem hangs indefinitely.
|
||||||
|
|
|
@ -16,13 +16,12 @@ const (
|
||||||
stateLive = "live"
|
stateLive = "live"
|
||||||
)
|
)
|
||||||
|
|
||||||
// StateInfo contains description about the new state container has entered.
|
// CommonStateInfo contains the state info common to all platforms.
|
||||||
type StateInfo struct { // FIXME: event?
|
type CommonStateInfo struct { // FIXME: event?
|
||||||
State string
|
State string
|
||||||
Pid uint32
|
Pid uint32
|
||||||
ExitCode uint32
|
ExitCode uint32
|
||||||
ProcessID string
|
ProcessID string
|
||||||
OOMKilled bool // TODO Windows containerd factor out
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Backend defines callbacks that the client of the library needs to implement.
|
// Backend defines callbacks that the client of the library needs to implement.
|
||||||
|
|
|
@ -33,6 +33,14 @@ type Process struct {
|
||||||
SelinuxLabel *string `json:"selinuxLabel,omitempty"`
|
SelinuxLabel *string `json:"selinuxLabel,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// StateInfo contains description about the new state container has entered.
|
||||||
|
type StateInfo struct {
|
||||||
|
CommonStateInfo
|
||||||
|
|
||||||
|
// Platform specific StateInfo
|
||||||
|
OOMKilled bool
|
||||||
|
}
|
||||||
|
|
||||||
// Stats contains a stats properties from containerd.
|
// Stats contains a stats properties from containerd.
|
||||||
type Stats containerd.StatsResponse
|
type Stats containerd.StatsResponse
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,14 @@ type Summary struct {
|
||||||
Command string
|
Command string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// StateInfo contains description about the new state container has entered.
|
||||||
|
type StateInfo struct {
|
||||||
|
CommonStateInfo
|
||||||
|
|
||||||
|
// Platform specific StateInfo
|
||||||
|
UpdatePending bool
|
||||||
|
}
|
||||||
|
|
||||||
// Stats contains a stats properties from containerd.
|
// Stats contains a stats properties from containerd.
|
||||||
type Stats struct{}
|
type Stats struct{}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue