summaryrefslogtreecommitdiff
path: root/daemon/execdriver/native/driver.go
diff options
context:
space:
mode:
Diffstat (limited to 'daemon/execdriver/native/driver.go')
-rw-r--r--daemon/execdriver/native/driver.go41
1 files changed, 21 insertions, 20 deletions
diff --git a/daemon/execdriver/native/driver.go b/daemon/execdriver/native/driver.go
index 840d9fbc41..90333703c5 100644
--- a/daemon/execdriver/native/driver.go
+++ b/daemon/execdriver/native/driver.go
@@ -27,7 +27,7 @@ const (
func init() {
execdriver.RegisterInitFunc(DriverName, func(args *execdriver.InitArgs) error {
- var container *libcontainer.Container
+ var container *libcontainer.Config
f, err := os.Open(filepath.Join(args.Root, "container.json"))
if err != nil {
return err
@@ -54,7 +54,7 @@ func init() {
}
type activeContainer struct {
- container *libcontainer.Container
+ container *libcontainer.Config
cmd *exec.Cmd
}
@@ -83,7 +83,7 @@ func NewDriver(root, initPath string) (*driver, error) {
}
func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallback execdriver.StartCallback) (int, error) {
- // take the Command and populate the libcontainer.Container from it
+ // take the Command and populate the libcontainer.Config from it
container, err := d.createContainer(c)
if err != nil {
return -1, err
@@ -110,7 +110,7 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba
term := getTerminal(c, pipes)
- return namespaces.Exec(container, term, c.Rootfs, dataPath, args, func(container *libcontainer.Container, console, rootfs, dataPath, init string, child *os.File, args []string) *exec.Cmd {
+ return namespaces.Exec(container, term, c.Rootfs, dataPath, args, func(container *libcontainer.Config, console, rootfs, dataPath, init string, child *os.File, args []string) *exec.Cmd {
// we need to join the rootfs because namespaces will setup the rootfs and chroot
initPath := filepath.Join(c.Rootfs, c.InitPath)
@@ -171,21 +171,30 @@ func (d *driver) Unpause(c *execdriver.Command) error {
func (d *driver) Terminate(p *execdriver.Command) error {
// lets check the start time for the process
- started, err := d.readStartTime(p)
+ state, err := libcontainer.GetState(filepath.Join(d.root, p.ID))
if err != nil {
- // if we don't have the data on disk then we can assume the process is gone
- // because this is only removed after we know the process has stopped
- if os.IsNotExist(err) {
- return nil
+ if !os.IsNotExist(err) {
+ return err
}
- return err
+ // TODO: Remove this part for version 1.2.0
+ // This is added only to ensure smooth upgrades from pre 1.1.0 to 1.1.0
+ data, err := ioutil.ReadFile(filepath.Join(d.root, p.ID, "start"))
+ if err != nil {
+ // if we don't have the data on disk then we can assume the process is gone
+ // because this is only removed after we know the process has stopped
+ if os.IsNotExist(err) {
+ return nil
+ }
+ return err
+ }
+ state = &libcontainer.State{InitStartTime: string(data)}
}
currentStartTime, err := system.GetProcessStartTime(p.Process.Pid)
if err != nil {
return err
}
- if started == currentStartTime {
+ if state.InitStartTime == currentStartTime {
err = syscall.Kill(p.Process.Pid, 9)
syscall.Wait4(p.Process.Pid, nil, 0, nil)
}
@@ -194,14 +203,6 @@ func (d *driver) Terminate(p *execdriver.Command) error {
}
-func (d *driver) readStartTime(p *execdriver.Command) (string, error) {
- data, err := ioutil.ReadFile(filepath.Join(d.root, p.ID, "start"))
- if err != nil {
- return "", err
- }
- return string(data), nil
-}
-
func (d *driver) Info(id string) execdriver.Info {
return &info{
ID: id,
@@ -229,7 +230,7 @@ func (d *driver) GetPidsForContainer(id string) ([]int, error) {
return fs.GetPids(c)
}
-func (d *driver) writeContainerFile(container *libcontainer.Container, id string) error {
+func (d *driver) writeContainerFile(container *libcontainer.Config, id string) error {
data, err := json.Marshal(container)
if err != nil {
return err