Working tty and io support in shim

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby 2017-01-26 11:29:19 -08:00
parent 8e5e9ae70e
commit b59bd59d8a
9 changed files with 171 additions and 79 deletions

View file

@ -59,15 +59,24 @@ type EventType int32
const ( const (
EventType_EXIT EventType = 0 EventType_EXIT EventType = 0
EventType_OOM EventType = 1 EventType_OOM EventType = 1
EventType_CREATED EventType = 2
EventType_STARTED EventType = 3
EventType_EXEC_ADDED EventType = 4
) )
var EventType_name = map[int32]string{ var EventType_name = map[int32]string{
0: "EXIT", 0: "EXIT",
1: "OOM", 1: "OOM",
2: "CREATED",
3: "STARTED",
4: "EXEC_ADDED",
} }
var EventType_value = map[string]int32{ var EventType_value = map[string]int32{
"EXIT": 0, "EXIT": 0,
"OOM": 1, "OOM": 1,
"CREATED": 2,
"STARTED": 3,
"EXEC_ADDED": 4,
} }
func (x EventType) String() string { func (x EventType) String() string {
@ -3244,58 +3253,60 @@ var (
func init() { proto.RegisterFile("shim.proto", fileDescriptorShim) } func init() { proto.RegisterFile("shim.proto", fileDescriptorShim) }
var fileDescriptorShim = []byte{ var fileDescriptorShim = []byte{
// 835 bytes of a gzipped FileDescriptorProto // 868 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x84, 0x54, 0xcf, 0x6f, 0xe3, 0x44, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x84, 0x54, 0x4d, 0x6f, 0xeb, 0x44,
0x14, 0xae, 0x63, 0xe7, 0x47, 0x5f, 0x7e, 0xb4, 0x8c, 0x56, 0xd5, 0x6c, 0x00, 0x37, 0x98, 0x03, 0x14, 0xad, 0x63, 0xe7, 0xa3, 0x37, 0x1f, 0x0d, 0xa3, 0xa7, 0x6a, 0x5e, 0x80, 0x34, 0x98, 0x05,
0x61, 0x85, 0x52, 0x5a, 0xb8, 0x72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d0, 0xc8, 0x05, 0x53, 0xbd, 0xda, 0x96, 0x98, 0xfa, 0xcf, 0x77, 0x0c, 0xab, 0x78, 0xa6, 0x27, 0x16, 0x76, 0x01, 0x8e, 0x16, 0x10, 0x3a, 0x2a, 0xbc, 0x97, 0xad,
0x96, 0x7c, 0x6e, 0xbd, 0xfc, 0xe0, 0xcd, 0x83, 0xbb, 0xf7, 0xd7, 0x83, 0xbb, 0xf7, 0xef, 0x83, 0x75, 0x75, 0x7a, 0xbb, 0x0b, 0xf2, 0x56, 0xdf, 0x81, 0x3d, 0x52, 0x4b, 0xd4, 0x2d, 0x2a, 0xdc,
0x6b, 0xfd, 0xb2, 0x72, 0xad, 0x37, 0x2b, 0xd7, 0xfa, 0x63, 0xe5, 0x5a, 0xff, 0xac, 0x5c, 0x6b, 0x4a, 0x70, 0xe7, 0x6a, 0x6f, 0xa0, 0x92, 0x49, 0xab, 0x78, 0xb5, 0x47, 0xb2, 0xeb, 0xbc, 0xdc,
0xda, 0x30, 0xf7, 0x7e, 0xf1, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x8e, 0xcb, 0x80, 0x34, 0x16, 0x59, 0xf2, 0xb5, 0xf5, 0xfa, 0x93, 0xf7, 0xf7, 0xdd, 0xbd, 0xbf, 0xee, 0xbb, 0x7b, 0xff, 0xde,
0x07, 0x00, 0x00, 0x77, 0xad, 0x5f, 0x56, 0x5d, 0xeb, 0xfd, 0xaa, 0x6b, 0xfd, 0xb1, 0xea, 0x5a, 0xff, 0xac, 0xba,
0xd6, 0xb4, 0x62, 0xce, 0xfd, 0xe6, 0xbf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x58, 0x7a, 0x4f, 0x1d,
0x40, 0x07, 0x00, 0x00,
} }

View file

@ -84,6 +84,9 @@ message EventsRequest {
enum EventType { enum EventType {
EXIT = 0; EXIT = 0;
OOM = 1; OOM = 1;
CREATED = 2;
STARTED = 3;
EXEC_ADDED = 4;
} }
message Event { message Event {

View file

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"os" "os"
"os/signal" "os/signal"
"strings"
"syscall" "syscall"
"google.golang.org/grpc" "google.golang.org/grpc"
@ -90,7 +91,8 @@ func serve(server *grpc.Server, path string) error {
logrus.WithField("socket", path).Debug("serving api on unix socket") logrus.WithField("socket", path).Debug("serving api on unix socket")
go func() { go func() {
defer l.Close() defer l.Close()
if err := server.Serve(l); err != nil { if err := server.Serve(l); err != nil &&
!strings.Contains(err.Error(), "use of closed network connection") {
l.Close() l.Close()
logrus.WithError(err).Fatal("containerd-shim: GRPC server failure") logrus.WithError(err).Fatal("containerd-shim: GRPC server failure")
} }
@ -119,7 +121,7 @@ func handleSignals(signals chan os.Signal, server *grpc.Server, service *shim.Se
case syscall.SIGTERM, syscall.SIGINT: case syscall.SIGTERM, syscall.SIGINT:
// TODO: should we forward signals to the processes if they are still running? // TODO: should we forward signals to the processes if they are still running?
// i.e. machine reboot // i.e. machine reboot
server.GracefulStop() server.Stop()
return nil return nil
} }
} }

View file

@ -14,6 +14,7 @@ import (
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/grpclog" "google.golang.org/grpc/grpclog"
"github.com/crosbymichael/console"
"github.com/docker/containerd/api/shim" "github.com/docker/containerd/api/shim"
"github.com/urfave/cli" "github.com/urfave/cli"
) )
@ -31,6 +32,10 @@ var fifoFlags = []cli.Flag{
Name: "stderr", Name: "stderr",
Usage: "specify the path to the stderr fifo", Usage: "specify the path to the stderr fifo",
}, },
cli.BoolFlag{
Name: "tty,t",
Usage: "enable tty support",
},
} }
var shimCommand = cli.Command{ var shimCommand = cli.Command{
@ -40,6 +45,7 @@ var shimCommand = cli.Command{
shimCreateCommand, shimCreateCommand,
shimStartCommand, shimStartCommand,
shimDeleteCommand, shimDeleteCommand,
shimEventsCommand,
}, },
Action: func(context *cli.Context) error { Action: func(context *cli.Context) error {
cmd := exec.Command("containerd-shim", "--debug") cmd := exec.Command("containerd-shim", "--debug")
@ -80,7 +86,8 @@ var shimCreateCommand = cli.Command{
if err != nil { if err != nil {
return err return err
} }
wg, err := prepareStdio(context.String("stdin"), context.String("stdout"), context.String("stderr"), false) tty := context.Bool("tty")
wg, err := prepareStdio(context.String("stdin"), context.String("stdout"), context.String("stderr"), tty)
if err != nil { if err != nil {
return err return err
} }
@ -91,12 +98,31 @@ var shimCreateCommand = cli.Command{
Stdin: context.String("stdin"), Stdin: context.String("stdin"),
Stdout: context.String("stdout"), Stdout: context.String("stdout"),
Stderr: context.String("stderr"), Stderr: context.String("stderr"),
Terminal: tty,
}) })
if err != nil { if err != nil {
return err return err
} }
fmt.Printf("container created with id %s and pid %d\n", id, r.Pid) fmt.Printf("container created with id %s and pid %d\n", id, r.Pid)
if context.Bool("attach") { if context.Bool("attach") {
if tty {
current := console.Current()
defer current.Reset()
if err := current.SetRaw(); err != nil {
return err
}
size, err := current.Size()
if err != nil {
return err
}
if _, err := service.Pty(gocontext.Background(), &shim.PtyRequest{
Pid: r.Pid,
Width: uint32(size.Width),
Height: uint32(size.Height),
}); err != nil {
return err
}
}
wg.Wait() wg.Wait()
} }
return nil return nil
@ -133,6 +159,29 @@ var shimDeleteCommand = cli.Command{
}, },
} }
var shimEventsCommand = cli.Command{
Name: "events",
Usage: "get events for a shim",
Action: func(context *cli.Context) error {
service, err := getShimService()
if err != nil {
return err
}
events, err := service.Events(gocontext.Background(), &shim.EventsRequest{})
if err != nil {
return err
}
for {
e, err := events.Recv()
if err != nil {
return err
}
fmt.Printf("type=%s id=%s pid=%d status=%d\n", e.Type, e.ID, e.Pid, e.ExitStatus)
}
return nil
},
}
func getShimService() (shim.ShimClient, error) { func getShimService() (shim.ShimClient, error) {
bindSocket := "shim.sock" bindSocket := "shim.sock"

View file

@ -7,6 +7,7 @@ import (
"path/filepath" "path/filepath"
"sync" "sync"
"github.com/crosbymichael/console"
runc "github.com/crosbymichael/go-runc" runc "github.com/crosbymichael/go-runc"
apishim "github.com/docker/containerd/api/shim" apishim "github.com/docker/containerd/api/shim"
specs "github.com/opencontainers/runtime-spec/specs-go" specs "github.com/opencontainers/runtime-spec/specs-go"
@ -16,7 +17,7 @@ type execProcess struct {
sync.WaitGroup sync.WaitGroup
id string id string
console *runc.Console console console.Console
io runc.IO io runc.IO
status int status int
pid int pid int
@ -42,6 +43,7 @@ func newExecProcess(context context.Context, r *apishim.ExecRequest, parent *ini
if socket, err = runc.NewConsoleSocket(filepath.Join(cwd, "pty.sock")); err != nil { if socket, err = runc.NewConsoleSocket(filepath.Join(cwd, "pty.sock")); err != nil {
return nil, err return nil, err
} }
defer os.Remove(socket.Path())
} else { } else {
// TODO: get uid/gid // TODO: get uid/gid
if io, err = runc.NewPipeIO(0, 0); err != nil { if io, err = runc.NewPipeIO(0, 0); err != nil {
@ -108,10 +110,12 @@ func (e *execProcess) Status() int {
func (e *execProcess) Exited(status int) { func (e *execProcess) Exited(status int) {
e.status = status e.status = status
e.Wait() e.Wait()
if e.io != nil {
e.io.Close() e.io.Close()
} }
}
func (e *execProcess) Resize(ws runc.WinSize) error { func (e *execProcess) Resize(ws console.WinSize) error {
if e.console == nil { if e.console == nil {
return nil return nil
} }

View file

@ -7,6 +7,7 @@ import (
"sync" "sync"
"syscall" "syscall"
"github.com/crosbymichael/console"
runc "github.com/crosbymichael/go-runc" runc "github.com/crosbymichael/go-runc"
apishim "github.com/docker/containerd/api/shim" apishim "github.com/docker/containerd/api/shim"
) )
@ -16,7 +17,7 @@ type initProcess struct {
id string id string
bundle string bundle string
console *runc.Console console console.Console
io runc.IO io runc.IO
runc *runc.Runc runc *runc.Runc
status int status int
@ -47,6 +48,7 @@ func newInitProcess(context context.Context, r *apishim.CreateRequest) (*initPro
if socket, err = runc.NewConsoleSocket(filepath.Join(cwd, "pty.sock")); err != nil { if socket, err = runc.NewConsoleSocket(filepath.Join(cwd, "pty.sock")); err != nil {
return nil, err return nil, err
} }
defer os.Remove(socket.Path())
} else { } else {
// TODO: get uid/gid // TODO: get uid/gid
if io, err = runc.NewPipeIO(0, 0); err != nil { if io, err = runc.NewPipeIO(0, 0); err != nil {
@ -105,11 +107,13 @@ func (p *initProcess) Delete(context context.Context) error {
p.killAll(context) p.killAll(context)
p.Wait() p.Wait()
err := p.runc.Delete(context, p.id) err := p.runc.Delete(context, p.id)
if p.io != nil {
p.io.Close() p.io.Close()
}
return err return err
} }
func (p *initProcess) Resize(ws runc.WinSize) error { func (p *initProcess) Resize(ws console.WinSize) error {
if p.console == nil { if p.console == nil {
return nil return nil
} }

View file

@ -7,11 +7,12 @@ import (
"sync" "sync"
"syscall" "syscall"
"github.com/crosbymichael/console"
runc "github.com/crosbymichael/go-runc" runc "github.com/crosbymichael/go-runc"
"github.com/tonistiigi/fifo" "github.com/tonistiigi/fifo"
) )
func copyConsole(ctx context.Context, console *runc.Console, stdin, stdout, stderr string, wg *sync.WaitGroup) error { func copyConsole(ctx context.Context, console console.Console, stdin, stdout, stderr string, wg *sync.WaitGroup) error {
in, err := fifo.OpenFifo(ctx, stdin, syscall.O_RDONLY, 0) in, err := fifo.OpenFifo(ctx, stdin, syscall.O_RDONLY, 0)
if err != nil { if err != nil {
return err return err

View file

@ -1,12 +1,12 @@
package shim package shim
import runc "github.com/crosbymichael/go-runc" import "github.com/crosbymichael/console"
type process interface { type process interface {
// Pid returns the pid for the process // Pid returns the pid for the process
Pid() int Pid() int
// Resize resizes the process console // Resize resizes the process console
Resize(ws runc.WinSize) error Resize(ws console.WinSize) error
// Exited sets the exit status for the process // Exited sets the exit status for the process
Exited(status int) Exited(status int)
// Status returns the exit status // Status returns the exit status

View file

@ -4,7 +4,7 @@ import (
"fmt" "fmt"
"sync" "sync"
runc "github.com/crosbymichael/go-runc" "github.com/crosbymichael/console"
apishim "github.com/docker/containerd/api/shim" apishim "github.com/docker/containerd/api/shim"
"github.com/docker/containerd/utils" "github.com/docker/containerd/utils"
google_protobuf "github.com/golang/protobuf/ptypes/empty" google_protobuf "github.com/golang/protobuf/ptypes/empty"
@ -17,7 +17,7 @@ var emptyResponse = &google_protobuf.Empty{}
func NewService() *Service { func NewService() *Service {
return &Service{ return &Service{
processes: make(map[int]process), processes: make(map[int]process),
events: make(chan *apishim.Event, 2048), events: make(chan *apishim.Event, 4096),
} }
} }
@ -40,6 +40,11 @@ func (s *Service) Create(ctx context.Context, r *apishim.CreateRequest) (*apishi
s.processes[pid] = process s.processes[pid] = process
s.id = r.ID s.id = r.ID
s.mu.Unlock() s.mu.Unlock()
s.events <- &apishim.Event{
Type: apishim.EventType_CREATED,
ID: r.ID,
Pid: uint32(pid),
}
return &apishim.CreateResponse{ return &apishim.CreateResponse{
Pid: uint32(pid), Pid: uint32(pid),
}, nil }, nil
@ -49,6 +54,11 @@ func (s *Service) Start(ctx context.Context, r *apishim.StartRequest) (*google_p
if err := s.initProcess.Start(ctx); err != nil { if err := s.initProcess.Start(ctx); err != nil {
return nil, err return nil, err
} }
s.events <- &apishim.Event{
Type: apishim.EventType_STARTED,
ID: s.id,
Pid: uint32(s.initProcess.Pid()),
}
return emptyResponse, nil return emptyResponse, nil
} }
@ -73,13 +83,21 @@ func (s *Service) Exec(ctx context.Context, r *apishim.ExecRequest) (*apishim.Ex
} }
pid := process.Pid() pid := process.Pid()
s.processes[pid] = process s.processes[pid] = process
s.events <- &apishim.Event{
Type: apishim.EventType_EXEC_ADDED,
ID: s.id,
Pid: uint32(pid),
}
return &apishim.ExecResponse{ return &apishim.ExecResponse{
Pid: uint32(pid), Pid: uint32(pid),
}, nil }, nil
} }
func (s *Service) Pty(ctx context.Context, r *apishim.PtyRequest) (*google_protobuf.Empty, error) { func (s *Service) Pty(ctx context.Context, r *apishim.PtyRequest) (*google_protobuf.Empty, error) {
ws := runc.WinSize{ if r.Pid == 0 {
return nil, fmt.Errorf("pid not provided in request")
}
ws := console.WinSize{
Width: uint16(r.Width), Width: uint16(r.Width),
Height: uint16(r.Height), Height: uint16(r.Height),
} }