2016-03-18 14:53:27 -04:00
|
|
|
package daemon
|
|
|
|
|
|
|
|
import (
|
2016-04-01 20:02:38 -04:00
|
|
|
"fmt"
|
|
|
|
|
2016-03-18 14:53:27 -04: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-01 20:02:38 -04: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-06 21:07:01 -04:00
|
|
|
if e.ExitCode == 0 && e.UpdatePending {
|
2016-04-13 16:34:07 -04:00
|
|
|
spec, err := daemon.createSpec(container)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2016-10-04 15:30:07 -04:00
|
|
|
newOpts := []libcontainerd.CreateOption{&libcontainerd.ServicingOption{
|
2016-04-13 16:34:07 -04:00
|
|
|
IsServicing: true,
|
2016-10-04 15:30:07 -04:00
|
|
|
}}
|
|
|
|
|
|
|
|
copts, err := daemon.getLibcontainerdCreateOptions(container)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if copts != nil {
|
2016-10-05 16:29:56 -04:00
|
|
|
newOpts = append(newOpts, copts...)
|
2016-04-13 16:34:07 -04: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 17:39:52 -04:00
|
|
|
if err := daemon.containerd.Create((container.ID + "_servicing"), "", "", *spec, container.InitializeStdio, newOpts...); err != nil {
|
2016-06-14 14:11:43 -04:00
|
|
|
container.SetExitCode(-1)
|
2016-04-13 16:34:07 -04:00
|
|
|
return fmt.Errorf("Post-run update servicing failed: %s", err)
|
|
|
|
}
|
2016-04-01 20:02:38 -04:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|