2016-03-18 18:53:27 +00:00
|
|
|
package daemon
|
|
|
|
|
|
|
|
import (
|
2016-04-02 00:02:38 +00:00
|
|
|
"fmt"
|
|
|
|
|
2016-03-18 18:53:27 +00:00
|
|
|
"github.com/docker/docker/container"
|
|
|
|
"github.com/docker/docker/libcontainerd"
|
|
|
|
)
|
|
|
|
|
|
|
|
// platformConstructExitStatus returns a platform specific exit status structure
|
|
|
|
func platformConstructExitStatus(e libcontainerd.StateInfo) *container.ExitStatus {
|
|
|
|
return &container.ExitStatus{
|
|
|
|
ExitCode: int(e.ExitCode),
|
|
|
|
}
|
|
|
|
}
|
2016-04-02 00:02:38 +00:00
|
|
|
|
|
|
|
// postRunProcessing perfoms any processing needed on the container after it has stopped.
|
|
|
|
func (daemon *Daemon) postRunProcessing(container *container.Container, e libcontainerd.StateInfo) error {
|
2016-06-07 01:07:01 +00:00
|
|
|
if e.ExitCode == 0 && e.UpdatePending {
|
2016-04-13 20:34:07 +00:00
|
|
|
spec, err := daemon.createSpec(container)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2016-10-04 19:30:07 +00:00
|
|
|
newOpts := []libcontainerd.CreateOption{&libcontainerd.ServicingOption{
|
2016-04-13 20:34:07 +00:00
|
|
|
IsServicing: true,
|
2016-10-04 19:30:07 +00:00
|
|
|
}}
|
|
|
|
|
|
|
|
copts, err := daemon.getLibcontainerdCreateOptions(container)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if copts != nil {
|
2016-10-05 20:29:56 +00:00
|
|
|
newOpts = append(newOpts, copts...)
|
2016-04-13 20:34:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Create a new servicing container, which will start, complete the update, and merge back the
|
|
|
|
// results if it succeeded, all as part of the below function call.
|
2016-10-17 21:39:52 +00:00
|
|
|
if err := daemon.containerd.Create((container.ID + "_servicing"), "", "", *spec, container.InitializeStdio, newOpts...); err != nil {
|
2016-06-14 18:11:43 +00:00
|
|
|
container.SetExitCode(-1)
|
2016-04-13 20:34:07 +00:00
|
|
|
return fmt.Errorf("Post-run update servicing failed: %s", err)
|
|
|
|
}
|
2016-04-02 00:02:38 +00:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|