Merge pull request #115 from docker/opts

Various fixes and improvements
This commit is contained in:
Michael Crosby 2016-02-29 10:48:41 -08:00
commit c242792f21
19 changed files with 323 additions and 206 deletions

View file

@ -144,7 +144,8 @@ func createAPIContainer(c runtime.Container, getPids bool) (*types.Container, er
procs = append(procs, appendToProcs)
}
var pids []int
if getPids {
state := c.State()
if getPids && (state == runtime.Running || state == runtime.Paused) {
if pids, err = c.Pids(); err != nil {
return nil, grpc.Errorf(codes.Internal, "get all pids for container")
}
@ -154,8 +155,9 @@ func createAPIContainer(c runtime.Container, getPids bool) (*types.Container, er
BundlePath: c.Path(),
Processes: procs,
Labels: c.Labels(),
Status: string(c.State()),
Status: string(state),
Pids: toUint32(pids),
Runtime: c.Runtime(),
}, nil
}

View file

@ -310,6 +310,7 @@ type Container struct {
Status string `protobuf:"bytes,4,opt,name=status" json:"status,omitempty"`
Labels []string `protobuf:"bytes,5,rep,name=labels" json:"labels,omitempty"`
Pids []uint32 `protobuf:"varint,6,rep,name=pids" json:"pids,omitempty"`
Runtime string `protobuf:"bytes,7,opt,name=runtime" json:"runtime,omitempty"`
}
func (m *Container) Reset() { *m = Container{} }
@ -1096,122 +1097,102 @@ var _API_serviceDesc = grpc.ServiceDesc{
}
var fileDescriptor0 = []byte{
// 1862 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xc4, 0x18, 0x49, 0x6f, 0x1c, 0x4d,
0xd5, 0xb3, 0xcf, 0xbc, 0x59, 0xec, 0xa9, 0x78, 0x19, 0xcf, 0xf7, 0x65, 0xa1, 0x05, 0x24, 0x6c,
0x56, 0x70, 0x12, 0x11, 0x21, 0x81, 0x94, 0x38, 0x01, 0x42, 0x62, 0x70, 0xda, 0xb6, 0xb8, 0x20,
0x8d, 0xda, 0xdd, 0xc5, 0x4c, 0xe3, 0x9e, 0xee, 0x4e, 0x77, 0x8d, 0x3d, 0xbe, 0x70, 0xe4, 0xc8,
0x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2f, 0x57, 0x13, 0xb5, 0xb6, 0x23, 0x80, 0xfc, 0x01, 0x82, 0x0c, 0x14, 0xf7, 0xd2,
0xcb, 0xce, 0x70, 0x7f, 0x05, 0x45, 0x2b, 0x39, 0x87, 0xad, 0xc5, 0x17, 0x05, 0xb2, 0x90, 0xd5,
0xc5, 0x5b, 0xff, 0xf0, 0xe1, 0x5a, 0xba, 0xa9, 0x76, 0xf1, 0x35, 0x41, 0xab, 0x5d, 0xf3, 0x4a,
0xa1, 0xd5, 0xae, 0x7d, 0x86, 0xd8, 0x20, 0xbf, 0x84, 0x5e, 0xf1, 0x7e, 0x4f, 0xb2, 0x24, 0xad,
0x7c, 0x9f, 0x18, 0xde, 0x5f, 0x43, 0xd5, 0x0a, 0x9f, 0x43, 0x4d, 0x5e, 0xdc, 0xb3, 0xde, 0x30,
0xef, 0xfb, 0xc3, 0xed, 0x22, 0x52, 0x4b, 0x3d, 0x85, 0xba, 0xbc, 0x13, 0xe9, 0x02, 0x28, 0x5c,
0x91, 0x86, 0x1d, 0x13, 0x6b, 0x6d, 0x3c, 0x2d, 0x65, 0x76, 0xd2, 0x82, 0x9d, 0x74, 0x95, 0x1d,
0x63, 0x73, 0x2e, 0xea, 0xe2, 0x29, 0xf7, 0xd9, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x46, 0x74,
0x2e, 0x01, 0xd7, 0x15, 0x00, 0x00,
// 1541 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xb4, 0x58, 0xeb, 0x6e, 0x1b, 0x45,
0x14, 0x8e, 0x2f, 0xb1, 0xe3, 0xe3, 0x4b, 0x92, 0xcd, 0xcd, 0x71, 0x29, 0x0d, 0xdb, 0x42, 0x2b,
0x54, 0x45, 0x25, 0xe5, 0x52, 0x8a, 0x84, 0x28, 0x69, 0x45, 0x41, 0x6d, 0x09, 0x4d, 0x82, 0xc4,
0x2f, 0x6b, 0x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 0xff, 0x0a, 0x94, 0xe5,
0x0c, 0x55, 0x11, 0x00, 0x00,
}

View file

@ -132,6 +132,7 @@ message Container {
string status = 4; // Container status ("running", "paused", etc.)
repeated string labels = 5;
repeated uint32 pids = 6;
string runtime = 7; // runtime used to execute the container
}
// Machine is information about machine on which containerd is run

View file

@ -12,15 +12,18 @@ import (
"github.com/docker/docker/pkg/term"
)
var runtimeLog string
func setupLogger() {
f, err := os.OpenFile("/tmp/shim.log", os.O_CREATE|os.O_RDWR|os.O_APPEND, 0755)
if err != nil {
panic(err)
}
logrus.SetOutput(f)
runtimeLog = "/tmp/runtime.log"
}
// containerd-shim is a small shim that sits in front of a runc implementation
// containerd-shim is a small shim that sits in front of a runtime implementation
// that allows it to be repartented to init and handle reattach from the caller.
//
// the cwd of the shim should be the bundle for the container. Arg1 should be the path
@ -28,31 +31,43 @@ func setupLogger() {
func main() {
flag.Parse()
// start handling signals as soon as possible so that things are properly reaped
// or if runc exits before we hit the handler
// or if runtime exits before we hit the handler
signals := make(chan os.Signal, 2048)
signal.Notify(signals)
// set the shim as the subreaper for all orphaned processes created by the container
if err := osutils.SetSubreaper(1); err != nil {
logrus.WithField("error", err).Fatal("shim: set as subreaper")
logrus.WithField("error", err).Error("shim: set as subreaper")
return
}
// open the exit pipe
f, err := os.OpenFile("exit", syscall.O_WRONLY, 0)
if err != nil {
logrus.WithField("error", err).Fatal("shim: open exit pipe")
logrus.WithField("error", err).Error("shim: open exit pipe")
return
}
defer f.Close()
control, err := os.OpenFile("control", syscall.O_RDWR, 0)
if err != nil {
logrus.WithField("error", err).Fatal("shim: open control pipe")
logrus.WithField("error", err).Error("shim: open control pipe")
return
}
defer control.Close()
p, err := newProcess(flag.Arg(0), flag.Arg(1))
p, err := newProcess(flag.Arg(0), flag.Arg(1), flag.Arg(2))
if err != nil {
logrus.WithField("error", err).Fatal("shim: create new process")
logrus.WithField("error", err).Error("shim: create new process")
return
}
defer func() {
if err := p.Close(); err != nil {
logrus.WithField("error", err).Error("shim: close stdio")
}
if err := p.delete(); err != nil {
logrus.WithField("error", err).Error("shim: delete runtime state")
}
}()
if err := p.start(); err != nil {
p.delete()
logrus.WithField("error", err).Fatal("shim: start process")
logrus.WithField("error", err).Error("shim: start process")
return
}
go func() {
for {
@ -87,13 +102,13 @@ func main() {
logrus.WithField("error", err).Error("shim: reaping child processes")
}
for _, e := range exits {
// check to see if runc is one of the processes that has exited
// check to see if runtime is one of the processes that has exited
if e.Pid == p.pid() {
exitShim = true
logrus.WithFields(logrus.Fields{
"pid": e.Pid,
"status": e.Status,
}).Info("shim: runc exited")
}).Info("shim: runtime exited")
if err := writeInt("exitStatus", e.Status); err != nil {
logrus.WithFields(logrus.Fields{
"error": err,
@ -103,14 +118,8 @@ func main() {
}
}
}
// runc has exited so the shim can also exit
// runtime has exited so the shim can also exit
if exitShim {
if err := p.Close(); err != nil {
logrus.WithField("error", err).Error("shim: close stdio")
}
if err := p.delete(); err != nil {
logrus.WithField("error", err).Error("shim: delete runc state")
}
return
}
}

View file

@ -2,6 +2,7 @@ package main
import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"os"
@ -25,12 +26,14 @@ type process struct {
console libcontainer.Console
consolePath string
state *runtime.ProcessState
runtime string
}
func newProcess(id, bundle string) (*process, error) {
func newProcess(id, bundle, runtimeName string) (*process, error) {
p := &process{
id: id,
bundle: bundle,
id: id,
bundle: bundle,
runtime: runtimeName,
}
s, err := loadProcess()
if err != nil {
@ -81,7 +84,7 @@ func (p *process) start() error {
if err != nil {
return err
}
args := []string{}
args := []string{"--log", runtimeLog}
if p.state.Exec {
args = append(args, "exec",
"--process", filepath.Join(cwd, "process.json"),
@ -114,7 +117,7 @@ func (p *process) start() error {
"--pid-file", filepath.Join(cwd, "pid"),
p.id,
)
cmd := exec.Command("runc", args...)
cmd := exec.Command(p.runtime, args...)
cmd.Dir = p.bundle
cmd.Stdin = p.stdio.stdin
cmd.Stdout = p.stdio.stdout
@ -146,7 +149,10 @@ func (p *process) pid() int {
func (p *process) delete() error {
if !p.state.Exec {
return exec.Command("runc", "delete", p.id).Run()
out, err := exec.Command(p.runtime, "delete", p.id).CombinedOutput()
if err != nil {
return fmt.Errorf("%s: %v", out, err)
}
}
return nil
}

View file

@ -41,6 +41,11 @@ var daemonFlags = []cli.Flag{
Value: defaultGRPCEndpoint,
Usage: "Address on which GRPC API will listen",
},
cli.StringFlag{
Name: "runtime,r",
Value: "runc",
Usage: "name of the OCI compliant runtime to use when executing containers",
},
}
func main() {
@ -58,6 +63,7 @@ func main() {
context.String("state-dir"),
10,
context.Bool("oom-notify"), // TODO Windows: Remove oom-notify
context.String("runtime"),
); err != nil {
logrus.Fatal(err)
}
@ -67,11 +73,11 @@ func main() {
}
}
func daemon(address, stateDir string, concurrency int, oom bool) error {
func daemon(address, stateDir string, concurrency int, oom bool, runtimeName string) error {
// setup a standard reaper so that we don't leave any zombies if we are still alive
// this is just good practice because we are spawning new processes
go reapProcesses()
sv, err := supervisor.New(stateDir, oom)
sv, err := supervisor.New(stateDir, oom, runtimeName)
if err != nil {
return err
}

View file

@ -92,6 +92,7 @@ func listContainers(context *cli.Context) {
}
w := tabwriter.NewWriter(os.Stdout, 20, 1, 3, ' ', 0)
fmt.Fprint(w, "ID\tPATH\tSTATUS\tPROCESSES\n")
sortContainers(resp.Containers)
for _, c := range resp.Containers {
procs := []string{}
for _, p := range c.Processes {

27
ctr/sort.go Normal file
View file

@ -0,0 +1,27 @@
package main
import (
"sort"
"github.com/docker/containerd/api/grpc/types"
)
func sortContainers(c []*types.Container) {
sort.Sort(&containerSorter{c})
}
type containerSorter struct {
c []*types.Container
}
func (s *containerSorter) Len() int {
return len(s.c)
}
func (s *containerSorter) Swap(i, j int) {
s.c[i], s.c[j] = s.c[j], s.c[i]
}
func (s *containerSorter) Less(i, j int) bool {
return s.c[i].Id < s.c[j].Id
}

View file

@ -5,6 +5,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"syscall"
"github.com/Sirupsen/logrus"
)
@ -42,6 +43,8 @@ type Container interface {
Pids() ([]int, error)
// Stats returns realtime container stats and resource information
Stats() (*Stat, error)
// Name or path of the OCI compliant runtime used to execute the container
Runtime() string
// OOM signals the channel if the container received an OOM notification
// OOM() (<-chan struct{}, error)
}
@ -68,13 +71,14 @@ func NewStdio(stdin, stdout, stderr string) Stdio {
}
// New returns a new container
func New(root, id, bundle string, labels []string) (Container, error) {
func New(root, id, bundle, runtimeName string, labels []string) (Container, error) {
c := &container{
root: root,
id: id,
bundle: bundle,
labels: labels,
processes: make(map[string]*process),
runtime: runtimeName,
}
if err := os.Mkdir(filepath.Join(root, id), 0755); err != nil {
return nil, err
@ -85,8 +89,9 @@ func New(root, id, bundle string, labels []string) (Container, error) {
}
defer f.Close()
if err := json.NewEncoder(f).Encode(state{
Bundle: bundle,
Labels: labels,
Bundle: bundle,
Labels: labels,
Runtime: runtimeName,
}); err != nil {
return nil, err
}
@ -108,6 +113,7 @@ func Load(root, id string) (Container, error) {
id: id,
bundle: s.Bundle,
labels: s.Labels,
runtime: s.Runtime,
processes: make(map[string]*process),
}
dirs, err := ioutil.ReadDir(filepath.Join(root, id))
@ -151,6 +157,7 @@ type container struct {
root string
id string
bundle string
runtime string
processes map[string]*process
stdio Stdio
labels []string
@ -182,6 +189,14 @@ func (c *container) readSpec() (*PlatformSpec, error) {
}
func (c *container) State() State {
proc := c.processes["init"]
if proc == nil || proc.pid == 0 {
return Stopped
}
err := syscall.Kill(proc.pid, 0)
if err != nil && err == syscall.ESRCH {
return Stopped
}
return Running
}

View file

@ -32,6 +32,10 @@ func getRootIDs(s *PlatformSpec) (int, int, error) {
return uid, gid, nil
}
func (c *container) Runtime() string {
return c.runtime
}
func (c *container) Pause() error {
return exec.Command("runc", "pause", c.id).Run()
}
@ -115,7 +119,7 @@ func (c *container) Start(checkpoint string, s Stdio) (Process, error) {
return nil, err
}
cmd := exec.Command("containerd-shim",
c.id, c.bundle,
c.id, c.bundle, c.runtime,
)
cmd.Dir = processRoot
cmd.SysProcAttr = &syscall.SysProcAttr{
@ -141,8 +145,8 @@ func (c *container) Start(checkpoint string, s Stdio) (Process, error) {
if err := cmd.Start(); err != nil {
return nil, err
}
if _, err := p.getPid(); err != nil {
return p, nil
if err := waitForStart(p, cmd); err != nil {
return nil, err
}
c.processes[InitProcessID] = p
return p, nil
@ -154,7 +158,7 @@ func (c *container) Exec(pid string, spec ProcessSpec, s Stdio) (Process, error)
return nil, err
}
cmd := exec.Command("containerd-shim",
c.id, c.bundle,
c.id, c.bundle, c.runtime,
)
cmd.Dir = processRoot
cmd.SysProcAttr = &syscall.SysProcAttr{
@ -175,8 +179,8 @@ func (c *container) Exec(pid string, spec ProcessSpec, s Stdio) (Process, error)
if err := cmd.Start(); err != nil {
return nil, err
}
if _, err := p.getPid(); err != nil {
return p, nil
if err := waitForStart(p, cmd); err != nil {
return nil, err
}
c.processes[pid] = p
return p, nil
@ -222,3 +226,34 @@ func (c *container) Stats() (*Stat, error) {
Data: stats,
}, nil
}
func waitForStart(p *process, cmd *exec.Cmd) error {
for i := 0; i < 50; i++ {
if _, err := p.getPidFromFile(); err != nil {
if os.IsNotExist(err) {
alive, err := isAlive(cmd)
if err != nil {
return err
}
if !alive {
return ErrContainerNotStarted
}
time.Sleep(100 * time.Millisecond)
continue
}
return err
}
return nil
}
return errNoPidFile
}
func isAlive(cmd *exec.Cmd) (bool, error) {
if err := syscall.Kill(cmd.Process.Pid, 0); err != nil {
if err == syscall.ESRCH {
return false, nil
}
return false, err
}
return true, nil
}

View file

@ -6,6 +6,10 @@ func getRootIDs(s *PlatformSpec) (int, int, error) {
return 0, 0, nil
}
func (c *container) Runtime() string {
return "windows"
}
func (c *container) Pause() error {
return errors.New("Pause not supported on Windows")
}

View file

@ -8,7 +8,6 @@ import (
"os"
"path/filepath"
"strconv"
"time"
)
type Process interface {
@ -95,7 +94,7 @@ func loadProcess(root, id string, c *container, s *ProcessState) (*process, erro
Stderr: s.Stderr,
},
}
if _, err := p.getPid(); err != nil {
if _, err := p.getPidFromFile(); err != nil {
return nil, err
}
if _, err := p.ExitStatus(); err != nil {
@ -177,22 +176,15 @@ func (p *process) Close() error {
return p.exitPipe.Close()
}
func (p *process) getPid() (int, error) {
for i := 0; i < 20; i++ {
data, err := ioutil.ReadFile(filepath.Join(p.root, "pid"))
if err != nil {
if os.IsNotExist(err) {
time.Sleep(100 * time.Millisecond)
continue
}
return -1, err
}
i, err := strconv.Atoi(string(data))
if err != nil {
return -1, err
}
p.pid = i
return i, nil
func (p *process) getPidFromFile() (int, error) {
data, err := ioutil.ReadFile(filepath.Join(p.root, "pid"))
if err != nil {
return -1, err
}
return -1, fmt.Errorf("containerd: cannot read pid file")
i, err := strconv.Atoi(string(data))
if err != nil {
return -1, err
}
p.pid = i
return i, nil
}

View file

@ -14,7 +14,9 @@ var (
ErrTerminalsNotSupported = errors.New("containerd: terminals are not supported for runtime")
ErrProcessNotExited = errors.New("containerd: process has not exited")
ErrProcessExited = errors.New("containerd: process has exited")
ErrContainerNotStarted = errors.New("containerd: container not started")
errNoPidFile = errors.New("containerd: no process pid file found")
errNotImplemented = errors.New("containerd: not implemented")
)
@ -30,15 +32,17 @@ type State string
const (
Paused = State("paused")
Stopped = State("stopped")
Running = State("running")
)
type state struct {
Bundle string `json:"bundle"`
Labels []string `json:"labels"`
Stdin string `json:"stdin"`
Stdout string `json:"stdout"`
Stderr string `json:"stderr"`
Bundle string `json:"bundle"`
Labels []string `json:"labels"`
Stdin string `json:"stdin"`
Stdout string `json:"stdout"`
Stderr string `json:"stderr"`
Runtime string `json:"runtime"`
}
type ProcessState struct {

View file

@ -2,5 +2,7 @@ package runtime
import "github.com/opencontainers/specs"
type PlatformSpec specs.LinuxSpec
type ProcessSpec specs.Process
type (
PlatformSpec specs.LinuxSpec
ProcessSpec specs.Process
)

View file

@ -20,7 +20,7 @@ type StartTask struct {
func (s *Supervisor) start(t *StartTask) error {
start := time.Now()
container, err := runtime.New(s.stateDir, t.ID, t.BundlePath, t.Labels)
container, err := runtime.New(s.stateDir, t.ID, t.BundlePath, s.runtime, t.Labels)
if err != nil {
return err
}

View file

@ -17,9 +17,19 @@ func (s *Supervisor) exit(t *ExitTask) error {
proc := t.Process
status, err := proc.ExitStatus()
if err != nil {
logrus.WithField("error", err).Error("containerd: get exit status")
logrus.WithFields(logrus.Fields{
"error": err,
"pid": proc.ID(),
"id": proc.Container().ID(),
"systemPid": proc.SystemPid(),
}).Error("containerd: get exit status")
}
logrus.WithFields(logrus.Fields{"pid": proc.ID(), "status": status}).Debug("containerd: process exited")
logrus.WithFields(logrus.Fields{
"pid": proc.ID(),
"status": status,
"id": proc.Container().ID(),
"systemPid": proc.SystemPid(),
}).Debug("containerd: process exited")
// if the process is the the init process of the container then
// fire a separate event for this process

27
supervisor/sort.go Normal file
View file

@ -0,0 +1,27 @@
package supervisor
import (
"sort"
"github.com/docker/containerd/runtime"
)
func sortProcesses(p []runtime.Process) {
sort.Sort(&processSorter{p})
}
type processSorter struct {
processes []runtime.Process
}
func (s *processSorter) Len() int {
return len(s.processes)
}
func (s *processSorter) Swap(i, j int) {
s.processes[i], s.processes[j] = s.processes[j], s.processes[i]
}
func (s *processSorter) Less(i, j int) bool {
return s.processes[j].ID() == "init"
}

View file

@ -6,7 +6,6 @@ import (
"io/ioutil"
"os"
"path/filepath"
"sort"
"sync"
"time"
@ -20,7 +19,7 @@ const (
)
// New returns an initialized Process supervisor.
func New(stateDir string, oom bool) (*Supervisor, error) {
func New(stateDir string, oom bool, runtimeName string) (*Supervisor, error) {
startTasks := make(chan *startTask, 10)
if err := os.MkdirAll(stateDir, 0755); err != nil {
return nil, err
@ -41,6 +40,7 @@ func New(stateDir string, oom bool) (*Supervisor, error) {
subscribers: make(map[chan Event]struct{}),
tasks: make(chan Task, defaultBufferSize),
monitor: monitor,
runtime: runtimeName,
}
if err := setupEventLog(s); err != nil {
return nil, err
@ -116,7 +116,9 @@ func readEventLog(s *Supervisor) error {
type Supervisor struct {
// stateDir is the directory on the system to store container runtime state information.
stateDir string
stateDir string
// name of the OCI compatible runtime used to execute containers
runtime string
containers map[string]*containerInfo
startTasks chan *startTask
// we need a lock around the subscribers map only because additions and deletions from
@ -207,7 +209,12 @@ func (s *Supervisor) notifySubscribers(e Event) {
// therefore it is save to do operations in the handlers that modify state of the system or
// state of the Supervisor
func (s *Supervisor) Start() error {
logrus.WithField("stateDir", s.stateDir).Debug("containerd: supervisor running")
logrus.WithFields(logrus.Fields{
"stateDir": s.stateDir,
"runtime": s.runtime,
"memory": s.machine.Memory,
"cpus": s.machine.Cpus,
}).Debug("containerd: supervisor running")
go func() {
for i := range s.tasks {
s.handleTask(i)
@ -277,7 +284,7 @@ func (s *Supervisor) restore() error {
if len(exitedProcesses) > 0 {
// sort processes so that init is fired last because that is how the kernel sends the
// exit events
sort.Sort(&processSorter{exitedProcesses})
sortProcesses(exitedProcesses)
for _, p := range exitedProcesses {
e := &ExitTask{
Process: p,
@ -288,19 +295,3 @@ func (s *Supervisor) restore() error {
}
return nil
}
type processSorter struct {
processes []runtime.Process
}
func (s *processSorter) Len() int {
return len(s.processes)
}
func (s *processSorter) Swap(i, j int) {
s.processes[i], s.processes[j] = s.processes[j], s.processes[i]
}
func (s *processSorter) Less(i, j int) bool {
return s.processes[j].ID() == "init"
}

View file

@ -40,11 +40,15 @@ func (w *worker) Start() {
started := time.Now()
process, err := t.Container.Start(t.Checkpoint, runtime.NewStdio(t.Stdin, t.Stdout, t.Stderr))
if err != nil {
logrus.WithFields(logrus.Fields{
"error": err,
"id": t.Container.ID(),
}).Error("containerd: start container")
t.Err <- err
evt := &DeleteTask{
ID: t.Container.ID(),
}
w.s.SendTask(evt)
t.Err <- err
continue
}
/*