New oom sync (#257)

* Vendor in runc afaa21f79ade3b2e99a68f3f15e7219155aa4662

This updates the Dockerfile to use go 1.6.2 and install pkg-config are
both are now needed by runc.

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>

* Add support for runc create/start operation

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>

* Remove dependency on runc state directory for OOM handler

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>

* Add OOM test

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
This commit is contained in:
Kenfe-Mickaël Laventure 2016-06-09 13:33:26 -07:00 committed by Michael Crosby
parent cf554d59dd
commit 8040df4e89
214 changed files with 215 additions and 30135 deletions

View file

@ -3,6 +3,7 @@ package main
import (
"flag"
"fmt"
"io/ioutil"
"os"
"os/signal"
"path/filepath"
@ -77,7 +78,7 @@ func start(log *os.File) error {
writeMessage(log, "warn", err)
}
}()
if err := p.start(); err != nil {
if err := p.create(); err != nil {
p.delete()
return err
}
@ -102,6 +103,11 @@ func start(log *os.File) error {
Height: uint16(h),
}
term.SetWinsize(p.console.Fd(), &ws)
case 2:
// tell runtime to execute the init process
if err := p.start(); err != nil {
syscall.Kill(p.pid(), syscall.SIGKILL)
}
}
}
}()
@ -120,6 +126,7 @@ func start(log *os.File) error {
}
// runtime has exited so the shim can also exit
if exitShim {
ioutil.WriteFile(fmt.Sprintf("/tmp/shim-delete-%d", p.pid()), []byte("deleting"), 0600)
p.delete()
p.Wait()
return nil

View file

@ -115,7 +115,7 @@ func loadCheckpoint(checkpointPath string) (*checkpoint, error) {
return &cpt, nil
}
func (p *process) start() error {
func (p *process) create() error {
cwd, err := os.Getwd()
if err != nil {
return err
@ -127,6 +127,7 @@ func (p *process) start() error {
}, p.state.RuntimeArgs...)
if p.state.Exec {
args = append(args, "exec",
"-d",
"--process", filepath.Join(cwd, "process.json"),
"--console", p.consolePath,
)
@ -151,7 +152,7 @@ func (p *process) start() error {
add("--no-pivot")
}
} else {
args = append(args, "start",
args = append(args, "create",
"--bundle", p.bundle,
"--console", p.consolePath,
)
@ -160,7 +161,6 @@ func (p *process) start() error {
}
}
args = append(args,
"-d",
"--pid-file", filepath.Join(cwd, "pid"),
p.id,
)
@ -200,6 +200,25 @@ func (p *process) start() error {
return nil
}
func (p *process) start() error {
cwd, err := os.Getwd()
if err != nil {
return err
}
logPath := filepath.Join(cwd, "log.json")
args := append([]string{
"--log", logPath,
"--log-format", "json",
}, p.state.RuntimeArgs...)
args = append(args, "start", p.id)
cmd := exec.Command(p.runtime, args...)
cmd.Dir = p.bundle
cmd.Stdin = p.stdio.stdin
cmd.Stdout = p.stdio.stdout
cmd.Stderr = p.stdio.stderr
return cmd.Run()
}
func (p *process) pid() int {
return p.containerPid
}