From 9890bed1e12b3b6a796cc44360eb4ebfb6dd445f Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Wed, 31 May 2017 15:53:42 -0700 Subject: [PATCH 1/6] Add CloseStdin to task Signed-off-by: Michael Crosby --- container_test.go | 85 +++++++++++++++++++++++++++++++++++++++++++++++ io.go | 26 +++++++++++++++ task.go | 9 +++++ 3 files changed, 120 insertions(+) diff --git a/container_test.go b/container_test.go index 00b9c43b0..44ac5cf5b 100644 --- a/container_test.go +++ b/container_test.go @@ -3,6 +3,9 @@ package containerd import ( "bytes" "context" + "fmt" + "io/ioutil" + "os" "syscall" "testing" ) @@ -360,3 +363,85 @@ func TestContainerProcesses(t *testing.T) { } <-statusC } + +func TestContainerCloseStdin(t *testing.T) { + if testing.Short() { + t.Skip() + } + client, err := New(address) + if err != nil { + t.Fatal(err) + } + defer client.Close() + + var ( + ctx = context.Background() + id = "ContainerCloseStdin" + ) + image, err := client.GetImage(ctx, testImage) + if err != nil { + t.Error(err) + return + } + spec, err := GenerateSpec(WithImageConfig(ctx, image), WithProcessArgs("cat")) + if err != nil { + t.Error(err) + return + } + container, err := client.NewContainer(ctx, id, spec, WithImage(image), WithNewRootFS(id, image)) + if err != nil { + t.Error(err) + return + } + defer container.Delete(ctx) + + const expected = "hello\n" + stdout := bytes.NewBuffer(nil) + + r, w, err := os.Pipe() + if err != nil { + t.Error(err) + return + } + + task, err := container.NewTask(ctx, NewIO(r, stdout, ioutil.Discard)) + if err != nil { + t.Error(err) + return + } + defer task.Delete(ctx) + + statusC := make(chan uint32, 1) + go func() { + status, err := task.Wait(ctx) + if err != nil { + t.Error(err) + } + statusC <- status + }() + + if err := task.Start(ctx); err != nil { + t.Error(err) + return + } + + if _, err := fmt.Fprint(w, expected); err != nil { + t.Error(err) + } + w.Close() + if err := task.CloseStdin(ctx); err != nil { + t.Error(err) + } + + <-statusC + + if _, err := task.Delete(ctx); err != nil { + t.Error(err) + } + + output := stdout.String() + + if output != expected { + t.Errorf("expected output %q but received %q", expected, output) + } +} diff --git a/io.go b/io.go index ea3325967..016053142 100644 --- a/io.go +++ b/io.go @@ -54,6 +54,32 @@ func BufferedIO(stdin, stdout, stderr *bytes.Buffer) IOCreation { } } +func NewIO(stdin io.Reader, stdout, stderr io.Writer) IOCreation { + return func() (*IO, error) { + paths, err := fifoPaths() + if err != nil { + return nil, err + } + i := &IO{ + Terminal: false, + Stdout: paths.out, + Stderr: paths.err, + Stdin: paths.in, + } + set := &ioSet{ + in: stdin, + out: stdout, + err: stderr, + } + closer, err := copyIO(paths, set, false) + if err != nil { + return nil, err + } + i.closer = closer + return i, nil + } +} + // Stdio returns an IO implementation to be used for a task // that outputs the container's IO as the current processes Stdio func Stdio() (*IO, error) { diff --git a/task.go b/task.go index ba5489a64..b56f0db99 100644 --- a/task.go +++ b/task.go @@ -32,6 +32,7 @@ type Task interface { Wait(context.Context) (uint32, error) Exec(context.Context, *specs.Process, IOCreation) (Process, error) Processes(context.Context) ([]uint32, error) + CloseStdin(context.Context) error } type Process interface { @@ -158,3 +159,11 @@ func (t *task) Processes(ctx context.Context) ([]uint32, error) { } return out, nil } + +func (t *task) CloseStdin(ctx context.Context) error { + _, err := t.client.TaskService().CloseStdin(ctx, &execution.CloseStdinRequest{ + ContainerID: t.containerID, + Pid: t.pid, + }) + return err +} From 1db752bca8f901a0134c50ee8de3e3476c882689 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Wed, 31 May 2017 15:55:07 -0700 Subject: [PATCH 2/6] Add CloseStdin to exec Process Signed-off-by: Michael Crosby --- process.go | 8 ++++++++ task.go | 1 + 2 files changed, 9 insertions(+) diff --git a/process.go b/process.go index 6a1fb552c..3f6edcd0d 100644 --- a/process.go +++ b/process.go @@ -88,3 +88,11 @@ func (p *process) Wait(ctx context.Context) (uint32, error) { } } } + +func (p *process) CloseStdin(ctx context.Context) error { + _, err := p.task.client.TaskService().CloseStdin(ctx, &execution.CloseStdinRequest{ + ContainerID: p.task.containerID, + Pid: p.pid, + }) + return err +} diff --git a/task.go b/task.go index b56f0db99..bee50db66 100644 --- a/task.go +++ b/task.go @@ -40,6 +40,7 @@ type Process interface { Start(context.Context) error Kill(context.Context, syscall.Signal) error Wait(context.Context) (uint32, error) + CloseStdin(context.Context) error } var _ = (Task)(&task{}) From 43fb19e01c2966bffb015073a55ca923b09db7cd Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Wed, 31 May 2017 16:29:41 -0700 Subject: [PATCH 3/6] Add Load for container and Task with Attach This adds both container and task loading of running tasks as well as reattaching to the IO of the task after load. Signed-off-by: Michael Crosby --- client.go | 10 ++++ container.go | 22 ++++++++ container_test.go | 136 +++++++++++++++++++++++++++++++++++++++++++++- io.go | 64 +++++++++++++--------- io_unix.go | 10 ++-- io_windows.go | 28 +++++----- task.go | 5 ++ 7 files changed, 228 insertions(+), 47 deletions(-) diff --git a/client.go b/client.go index 2047c373e..eacb1024b 100644 --- a/client.go +++ b/client.go @@ -203,6 +203,16 @@ func (c *Client) NewContainer(ctx context.Context, id string, spec *specs.Spec, return containerFromProto(c, r.Container), nil } +func (c *Client) LoadContainer(ctx context.Context, id string) (Container, error) { + response, err := c.ContainerService().Get(ctx, &containers.GetContainerRequest{ + ID: id, + }) + if err != nil { + return nil, err + } + return containerFromProto(c, response.Container), nil +} + type RemoteOpts func(*Client, *RemoteContext) error // RemoteContext is used to configure object resolutions and transfers with diff --git a/container.go b/container.go index 7b9bffd8d..1deec2602 100644 --- a/container.go +++ b/container.go @@ -16,6 +16,7 @@ type Container interface { NewTask(context.Context, IOCreation) (Task, error) Spec() (*specs.Spec, error) Task() Task + LoadTask(context.Context, IOCreation) (Task, error) } func containerFromProto(client *Client, c containers.Container) *container { @@ -108,3 +109,24 @@ func (c *container) NewTask(ctx context.Context, ioCreate IOCreation) (Task, err c.task = t return t, nil } + +func (c *container) LoadTask(ctx context.Context, ioCreate IOCreation) (Task, error) { + i, err := ioCreate() + if err != nil { + return nil, err + } + response, err := c.client.TaskService().Info(ctx, &execution.InfoRequest{ + ContainerID: c.c.ID, + }) + if err != nil { + return nil, err + } + t := &task{ + client: c.client, + io: i, + containerID: response.Task.ContainerID, + pid: response.Task.Pid, + } + c.task = t + return t, nil +} diff --git a/container_test.go b/container_test.go index 44ac5cf5b..f2e791072 100644 --- a/container_test.go +++ b/container_test.go @@ -4,14 +4,17 @@ import ( "bytes" "context" "fmt" + "io" "io/ioutil" "os" + "sync" "syscall" "testing" ) func empty() IOCreation { - return BufferedIO(bytes.NewBuffer(nil), bytes.NewBuffer(nil), bytes.NewBuffer(nil)) + null := ioutil.Discard + return NewIO(bytes.NewBuffer(nil), null, null) } func TestContainerList(t *testing.T) { @@ -170,7 +173,7 @@ func TestContainerOutput(t *testing.T) { defer container.Delete(ctx) stdout := bytes.NewBuffer(nil) - task, err := container.NewTask(ctx, BufferedIO(bytes.NewBuffer(nil), stdout, bytes.NewBuffer(nil))) + task, err := container.NewTask(ctx, NewIO(bytes.NewBuffer(nil), stdout, bytes.NewBuffer(nil))) if err != nil { t.Error(err) return @@ -445,3 +448,132 @@ func TestContainerCloseStdin(t *testing.T) { t.Errorf("expected output %q but received %q", expected, output) } } + +func TestContainerAttach(t *testing.T) { + if testing.Short() { + t.Skip() + } + client, err := New(address) + if err != nil { + t.Fatal(err) + } + defer client.Close() + + var ( + ctx = context.Background() + id = "ContainerAttach" + ) + image, err := client.GetImage(ctx, testImage) + if err != nil { + t.Error(err) + return + } + spec, err := GenerateSpec(WithImageConfig(ctx, image), WithProcessArgs("cat")) + if err != nil { + t.Error(err) + return + } + container, err := client.NewContainer(ctx, id, spec, WithImage(image), WithNewRootFS(id, image)) + if err != nil { + t.Error(err) + return + } + defer container.Delete(ctx) + + expected := "hello\n" + stdout := bytes.NewBuffer(nil) + + r, w, err := os.Pipe() + if err != nil { + t.Error(err) + return + } + or, ow, err := os.Pipe() + if err != nil { + t.Error(err) + return + } + + wg := &sync.WaitGroup{} + + wg.Add(1) + go func() { + io.Copy(stdout, or) + wg.Done() + }() + + // TODO: return fifo information from shim based on task/process + dir, err := ioutil.TempDir("", "attach") + if err != nil { + t.Error(err) + return + } + task, err := container.NewTask(ctx, WithIO(r, ow, ioutil.Discard, dir)) + if err != nil { + t.Error(err) + return + } + defer task.Delete(ctx) + originalIO := task.IO() + + statusC := make(chan uint32, 1) + go func() { + status, err := task.Wait(ctx) + if err != nil { + t.Error(err) + } + statusC <- status + }() + + if err := task.Start(ctx); err != nil { + t.Error(err) + return + } + + if _, err := fmt.Fprint(w, expected); err != nil { + t.Error(err) + } + w.Close() + + // load the container and re-load the task + if container, err = client.LoadContainer(ctx, id); err != nil { + t.Error(err) + return + } + + // create new IO for the loaded task + if r, w, err = os.Pipe(); err != nil { + t.Error(err) + return + } + if task, err = container.LoadTask(ctx, WithIO(r, ow, ioutil.Discard, dir)); err != nil { + t.Error(err) + return + } + + if _, err := fmt.Fprint(w, expected); err != nil { + t.Error(err) + } + w.Close() + + if err := task.CloseStdin(ctx); err != nil { + t.Error(err) + } + + <-statusC + + originalIO.Close() + if _, err := task.Delete(ctx); err != nil { + t.Error(err) + } + ow.Close() + + wg.Wait() + output := stdout.String() + + // we wrote the same thing after attach + expected = expected + expected + if output != expected { + t.Errorf("expected output %q but received %q", expected, output) + } +} diff --git a/io.go b/io.go index 016053142..e8c9f817c 100644 --- a/io.go +++ b/io.go @@ -1,7 +1,6 @@ package containerd import ( - "bytes" "io" "io/ioutil" "os" @@ -27,18 +26,17 @@ func (i *IO) Close() error { type IOCreation func() (*IO, error) -// BufferedIO returns IO that will be logged to an in memory buffer -func BufferedIO(stdin, stdout, stderr *bytes.Buffer) IOCreation { +func NewIO(stdin io.Reader, stdout, stderr io.Writer) IOCreation { return func() (*IO, error) { - paths, err := fifoPaths() + paths, err := NewFifos() if err != nil { return nil, err } i := &IO{ Terminal: false, - Stdout: paths.out, - Stderr: paths.err, - Stdin: paths.in, + Stdout: paths.Out, + Stderr: paths.Err, + Stdin: paths.In, } set := &ioSet{ in: stdin, @@ -54,17 +52,17 @@ func BufferedIO(stdin, stdout, stderr *bytes.Buffer) IOCreation { } } -func NewIO(stdin io.Reader, stdout, stderr io.Writer) IOCreation { +func WithIO(stdin io.Reader, stdout, stderr io.Writer, dir string) IOCreation { return func() (*IO, error) { - paths, err := fifoPaths() + paths, err := WithFifos(dir) if err != nil { return nil, err } i := &IO{ Terminal: false, - Stdout: paths.out, - Stderr: paths.err, - Stdin: paths.in, + Stdout: paths.Out, + Stderr: paths.Err, + Stdin: paths.In, } set := &ioSet{ in: stdin, @@ -83,7 +81,7 @@ func NewIO(stdin io.Reader, stdout, stderr io.Writer) IOCreation { // Stdio returns an IO implementation to be used for a task // that outputs the container's IO as the current processes Stdio func Stdio() (*IO, error) { - paths, err := fifoPaths() + paths, err := NewFifos() if err != nil { return nil, err } @@ -98,14 +96,15 @@ func Stdio() (*IO, error) { } return &IO{ Terminal: false, - Stdin: paths.in, - Stdout: paths.out, - Stderr: paths.err, + Stdin: paths.In, + Stdout: paths.Out, + Stderr: paths.Err, closer: closer, }, nil } -func fifoPaths() (*fifoSet, error) { +// NewFifos returns a new set of fifos for the task +func NewFifos() (*FifoSet, error) { root := filepath.Join(os.TempDir(), "containerd") if err := os.MkdirAll(root, 0700); err != nil { return nil, err @@ -114,18 +113,31 @@ func fifoPaths() (*fifoSet, error) { if err != nil { return nil, err } - return &fifoSet{ - dir: dir, - in: filepath.Join(dir, "stdin"), - out: filepath.Join(dir, "stdout"), - err: filepath.Join(dir, "stderr"), + return &FifoSet{ + Dir: dir, + In: filepath.Join(dir, "stdin"), + Out: filepath.Join(dir, "stdout"), + Err: filepath.Join(dir, "stderr"), }, nil } -type fifoSet struct { - // dir is the directory holding the task fifos - dir string - in, out, err string +// WithFifos returns existing or creates new fifos inside an existing dir +func WithFifos(dir string) (*FifoSet, error) { + if err := os.MkdirAll(dir, 0700); err != nil { + return nil, err + } + return &FifoSet{ + Dir: dir, + In: filepath.Join(dir, "stdin"), + Out: filepath.Join(dir, "stdout"), + Err: filepath.Join(dir, "stderr"), + }, nil +} + +type FifoSet struct { + // Dir is the directory holding the task fifos + Dir string + In, Out, Err string } type ioSet struct { diff --git a/io_unix.go b/io_unix.go index a243c3a52..5c0cf0091 100644 --- a/io_unix.go +++ b/io_unix.go @@ -11,14 +11,14 @@ import ( "github.com/containerd/fifo" ) -func copyIO(fifos *fifoSet, ioset *ioSet, tty bool) (closer io.Closer, err error) { +func copyIO(fifos *FifoSet, ioset *ioSet, tty bool) (closer io.Closer, err error) { var ( f io.ReadWriteCloser ctx = context.Background() wg = &sync.WaitGroup{} ) - if f, err = fifo.OpenFifo(ctx, fifos.in, syscall.O_WRONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0700); err != nil { + if f, err = fifo.OpenFifo(ctx, fifos.In, syscall.O_WRONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0700); err != nil { return nil, err } defer func(c io.Closer) { @@ -31,7 +31,7 @@ func copyIO(fifos *fifoSet, ioset *ioSet, tty bool) (closer io.Closer, err error w.Close() }(f) - if f, err = fifo.OpenFifo(ctx, fifos.out, syscall.O_RDONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0700); err != nil { + if f, err = fifo.OpenFifo(ctx, fifos.Out, syscall.O_RDONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0700); err != nil { return nil, err } defer func(c io.Closer) { @@ -46,7 +46,7 @@ func copyIO(fifos *fifoSet, ioset *ioSet, tty bool) (closer io.Closer, err error wg.Done() }(f) - if f, err = fifo.OpenFifo(ctx, fifos.err, syscall.O_RDONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0700); err != nil { + if f, err = fifo.OpenFifo(ctx, fifos.Err, syscall.O_RDONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0700); err != nil { return nil, err } defer func(c io.Closer) { @@ -66,6 +66,6 @@ func copyIO(fifos *fifoSet, ioset *ioSet, tty bool) (closer io.Closer, err error return &wgCloser{ wg: wg, - dir: fifos.dir, + dir: fifos.Dir, }, nil } diff --git a/io_windows.go b/io_windows.go index 4aa2ed5aa..2fb97566c 100644 --- a/io_windows.go +++ b/io_windows.go @@ -10,13 +10,13 @@ import ( "github.com/pkg/errors" ) -func copyIO(fifos *fifoSet, ioset *ioSet, tty bool) (closer io.Closer, err error) { +func copyIO(fifos *FifoSet, ioset *ioSet, tty bool) (closer io.Closer, err error) { var wg sync.WaitGroup - if fifos.in != "" { - l, err := winio.ListenPipe(fifos.in, nil) + if fifos.In != "" { + l, err := winio.ListenPipe(fifos.In, nil) if err != nil { - return nil, errors.Wrapf(err, "failed to create stdin pipe %s", fifos.in) + return nil, errors.Wrapf(err, "failed to create stdin pipe %s", fifos.In) } defer func(l net.Listener) { if err != nil { @@ -27,7 +27,7 @@ func copyIO(fifos *fifoSet, ioset *ioSet, tty bool) (closer io.Closer, err error go func() { c, err := l.Accept() if err != nil { - log.L.WithError(err).Errorf("failed to accept stdin connection on %s", fifos.in) + log.L.WithError(err).Errorf("failed to accept stdin connection on %s", fifos.In) return } io.Copy(c, ioset.in) @@ -36,10 +36,10 @@ func copyIO(fifos *fifoSet, ioset *ioSet, tty bool) (closer io.Closer, err error }() } - if fifos.out != "" { - l, err := winio.ListenPipe(fifos.out, nil) + if fifos.Out != "" { + l, err := winio.ListenPipe(fifos.Out, nil) if err != nil { - return nil, errors.Wrapf(err, "failed to create stdin pipe %s", fifos.out) + return nil, errors.Wrapf(err, "failed to create stdin pipe %s", fifos.Out) } defer func(l net.Listener) { if err != nil { @@ -52,7 +52,7 @@ func copyIO(fifos *fifoSet, ioset *ioSet, tty bool) (closer io.Closer, err error defer wg.Done() c, err := l.Accept() if err != nil { - log.L.WithError(err).Errorf("failed to accept stdout connection on %s", fifos.out) + log.L.WithError(err).Errorf("failed to accept stdout connection on %s", fifos.Out) return } io.Copy(ioset.out, c) @@ -61,10 +61,10 @@ func copyIO(fifos *fifoSet, ioset *ioSet, tty bool) (closer io.Closer, err error }() } - if !tty && fifos.err != "" { - l, err := winio.ListenPipe(fifos.err, nil) + if !tty && fifos.Err != "" { + l, err := winio.ListenPipe(fifos.Err, nil) if err != nil { - return nil, errors.Wrapf(err, "failed to create stderr pipe %s", fifos.err) + return nil, errors.Wrapf(err, "failed to create stderr pipe %s", fifos.Err) } defer func(l net.Listener) { if err != nil { @@ -77,7 +77,7 @@ func copyIO(fifos *fifoSet, ioset *ioSet, tty bool) (closer io.Closer, err error defer wg.Done() c, err := l.Accept() if err != nil { - log.L.WithError(err).Errorf("failed to accept stderr connection on %s", fifos.err) + log.L.WithError(err).Errorf("failed to accept stderr connection on %s", fifos.Err) return } io.Copy(ioset.err, c) @@ -88,6 +88,6 @@ func copyIO(fifos *fifoSet, ioset *ioSet, tty bool) (closer io.Closer, err error return &wgCloser{ wg: &wg, - dir: fifos.dir, + dir: fifos.Dir, }, nil } diff --git a/task.go b/task.go index bee50db66..21bf92a3f 100644 --- a/task.go +++ b/task.go @@ -33,6 +33,7 @@ type Task interface { Exec(context.Context, *specs.Process, IOCreation) (Process, error) Processes(context.Context) ([]uint32, error) CloseStdin(context.Context) error + IO() *IO } type Process interface { @@ -168,3 +169,7 @@ func (t *task) CloseStdin(ctx context.Context) error { }) return err } + +func (t *task) IO() *IO { + return t.io +} From 00734ab04ac0497034cd7ff3d9c68a1228de63a5 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Thu, 1 Jun 2017 13:36:44 -0700 Subject: [PATCH 4/6] Return fifo paths from Shim This allows attach of existing fifos to be done without any information stored on the client side. Signed-off-by: Michael Crosby --- api/services/shim/shim.pb.go | 303 ++++++++++++++++++++------- api/services/shim/shim.proto | 4 + api/types/task/task.pb.go | 377 +++++++++++++++++++++++++++++----- api/types/task/task.proto | 7 + container.go | 35 +++- container_test.go | 10 +- io.go | 25 +-- linux/shim/exec.go | 13 +- linux/shim/init.go | 18 +- linux/shim/service.go | 16 +- linux/task.go | 29 +-- metrics/cgroups/cgroups.go | 2 +- plugin/container.go | 10 +- services/execution/service.go | 14 +- windows/container.go | 5 +- windows/process.go | 5 +- 16 files changed, 682 insertions(+), 191 deletions(-) diff --git a/api/services/shim/shim.pb.go b/api/services/shim/shim.pb.go index d034825be..667e0e862 100644 --- a/api/services/shim/shim.pb.go +++ b/api/services/shim/shim.pb.go @@ -178,6 +178,10 @@ type StateResponse struct { Pid uint32 `protobuf:"varint,3,opt,name=pid,proto3" json:"pid,omitempty"` Status containerd_v1_types1.Status `protobuf:"varint,4,opt,name=status,proto3,enum=containerd.v1.types.Status" json:"status,omitempty"` Processes []*containerd_v1_types1.Process `protobuf:"bytes,5,rep,name=processes" json:"processes,omitempty"` + Stdin string `protobuf:"bytes,6,opt,name=stdin,proto3" json:"stdin,omitempty"` + Stdout string `protobuf:"bytes,7,opt,name=stdout,proto3" json:"stdout,omitempty"` + Stderr string `protobuf:"bytes,8,opt,name=stderr,proto3" json:"stderr,omitempty"` + Terminal bool `protobuf:"varint,9,opt,name=terminal,proto3" json:"terminal,omitempty"` } func (m *StateResponse) Reset() { *m = StateResponse{} } @@ -1229,6 +1233,34 @@ func (m *StateResponse) MarshalTo(dAtA []byte) (int, error) { i += n } } + if len(m.Stdin) > 0 { + dAtA[i] = 0x32 + i++ + i = encodeVarintShim(dAtA, i, uint64(len(m.Stdin))) + i += copy(dAtA[i:], m.Stdin) + } + if len(m.Stdout) > 0 { + dAtA[i] = 0x3a + i++ + i = encodeVarintShim(dAtA, i, uint64(len(m.Stdout))) + i += copy(dAtA[i:], m.Stdout) + } + if len(m.Stderr) > 0 { + dAtA[i] = 0x42 + i++ + i = encodeVarintShim(dAtA, i, uint64(len(m.Stderr))) + i += copy(dAtA[i:], m.Stderr) + } + if m.Terminal { + dAtA[i] = 0x48 + i++ + if m.Terminal { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i++ + } return i, nil } @@ -1702,6 +1734,21 @@ func (m *StateResponse) Size() (n int) { n += 1 + l + sovShim(uint64(l)) } } + l = len(m.Stdin) + if l > 0 { + n += 1 + l + sovShim(uint64(l)) + } + l = len(m.Stdout) + if l > 0 { + n += 1 + l + sovShim(uint64(l)) + } + l = len(m.Stderr) + if l > 0 { + n += 1 + l + sovShim(uint64(l)) + } + if m.Terminal { + n += 2 + } return n } @@ -1949,6 +1996,10 @@ func (this *StateResponse) String() string { `Pid:` + fmt.Sprintf("%v", this.Pid) + `,`, `Status:` + fmt.Sprintf("%v", this.Status) + `,`, `Processes:` + strings.Replace(fmt.Sprintf("%v", this.Processes), "Process", "containerd_v1_types1.Process", 1) + `,`, + `Stdin:` + fmt.Sprintf("%v", this.Stdin) + `,`, + `Stdout:` + fmt.Sprintf("%v", this.Stdout) + `,`, + `Stderr:` + fmt.Sprintf("%v", this.Stderr) + `,`, + `Terminal:` + fmt.Sprintf("%v", this.Terminal) + `,`, `}`, }, "") return s @@ -3425,6 +3476,113 @@ func (m *StateResponse) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Stdin", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowShim + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthShim + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Stdin = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Stdout", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowShim + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthShim + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Stdout = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Stderr", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowShim + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthShim + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Stderr = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Terminal", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowShim + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + m.Terminal = bool(v != 0) default: iNdEx = preIndex skippy, err := skipShim(dAtA[iNdEx:]) @@ -4251,76 +4409,77 @@ func init() { } var fileDescriptorShim = []byte{ - // 1136 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x56, 0xcb, 0x72, 0xe3, 0x44, - 0x17, 0x1e, 0xd9, 0x8e, 0x63, 0x1f, 0x8f, 0x9d, 0xa4, 0x2b, 0x95, 0xd2, 0x38, 0xff, 0xef, 0x04, - 0x55, 0x4d, 0x8d, 0x93, 0x01, 0x19, 0x32, 0xbb, 0x29, 0x58, 0xe4, 0x46, 0x31, 0x10, 0xc0, 0xd5, - 0x09, 0x2b, 0xaa, 0x70, 0x29, 0x72, 0xc7, 0x6e, 0x22, 0xab, 0x85, 0xba, 0x9d, 0x49, 0x76, 0x3c, - 0x00, 0x0b, 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a6, 0xfb, 0x50, 0x78, 0x96, - 0x7a, 0x45, 0x0a, 0x73, 0x62, 0x99, 0x24, 0x8e, 0xdc, 0xd4, 0x1f, 0x41, 0x59, 0x13, 0xca, 0x9c, - 0xd4, 0x4f, 0xb1, 0x4e, 0xae, 0xb5, 0x13, 0x80, 0x6c, 0x1c, 0xd1, 0xec, 0xb8, 0xee, 0xcc, 0x6d, - 0xae, 0xd5, 0x2f, 0xa0, 0x24, 0x39, 0x0e, 0xb5, 0x67, 0xda, 0x9b, 0xa0, 0xc1, 0x5c, 0x4b, 0x18, - 0xca, 0xfa, 0xd1, 0x98, 0x13, 0xed, 0xd4, 0xcb, 0xd2, 0xbc, 0xff, 0xd7, 0x47, 0x61, 0x3e, 0xb6, - 0xa4, 0x77, 0x92, 0x72, 0xe7, 0x78, 0x37, 0xc1, 0xca, 0xb9, 0xde, 0x7d, 0x2f, 0xe3, 0x24, 0xfe, - 0xdc, 0x38, 0xd3, 0xdf, 0x88, 0xe6, 0xd6, 0x03, 0x90, 0xa6, 0x69, 0x3e, 0x87, 0x62, 0x57, 0x5c, - 0xa1, 0x17, 0xb3, 0x5b, 0x26, 0x7d, 0x9f, 0x67, 0x96, 0x38, 0x7d, 0x16, 0xe6, 0x95, 0xf8, 0xf6, - 0xfb, 0x91, 0x67, 0x75, 0xcf, 0xbe, 0x7e, 0xdf, 0x7a, 0xf2, 0xf7, 0xfb, 0xd6, 0x93, 0x9f, 0x6f, - 0x5a, 0xd6, 0xf5, 0x4d, 0xcb, 0xfa, 0xf3, 0xa6, 0x65, 0xfd, 0x7b, 0xd3, 0xb2, 0x4e, 0xcb, 0x0a, - 0xf9, 0xea, 0xbf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x81, 0x12, 0xdb, 0xb6, 0xae, 0x0c, 0x00, 0x00, + // 1149 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x4f, 0x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0xd8, 0xa0, 0xf4, 0x4d, 0x48, 0xd0, 0x0b, 0x58, + 0x8e, 0xbc, 0x98, 0x84, 0xa2, 0x37, 0x01, 0xab, 0x29, 0xd8, 0x92, 0x3e, 0xd8, 0x4b, 0xe5, 0x8e, + 0x03, 0x8d, 0x24, 0xb0, 0x3c, 0x62, 0x21, 0x27, 0x68, 0x09, 0x8a, 0x91, 0x09, 0x6d, 0x1d, 0xcb, + 0xa5, 0xd3, 0x80, 0x27, 0x47, 0xc2, 0x8b, 0x85, 0x89, 0xbd, 0xf3, 0x01, 0xd4, 0xf7, 0x49, 0x40, + 0x32, 0x32, 0x6e, 0x5f, 0x11, 0xd0, 0x48, 0x20, 0x46, 0xed, 0x3a, 0xd4, 0xc8, 0x05, 0x15, 0x3d, + 0x2e, 0x3c, 0x31, 0xe6, 0x06, 0x0b, 0x52, 0x74, 0xa4, 0x24, 0x68, 0x07, 0xaa, 0x72, 0x47, 0xfa, + 0x3d, 0x4f, 0x28, 0xf2, 0x64, 0x34, 0x74, 0x62, 0xb8, 0x49, 0x62, 0xb8, 0xc7, 0x49, 0x62, 0xec, + 0x56, 0xae, 0xde, 0xae, 0x3f, 0xfa, 0xf5, 0x9f, 0x75, 0x0b, 0x57, 0xf4, 0xb5, 0x1d, 0xe1, 0xfc, + 0x66, 0x41, 0xed, 0xe0, 0x82, 0xf8, 0x89, 0x5d, 0x93, 0xfc, 0x59, 0x79, 0xfc, 0x15, 0xee, 0xe6, + 0xaf, 0x98, 0xc3, 0x5f, 0x69, 0x8a, 0xbf, 0x36, 0x94, 0x78, 0x44, 0x7c, 0x95, 0x1d, 0xb5, 0xed, + 0x95, 0x5b, 0xf6, 0xee, 0x84, 0x97, 0x58, 0x21, 0x9c, 0x7d, 0x28, 0xe3, 0x80, 0x8e, 0xa8, 0x40, + 0x08, 0x4a, 0x92, 0x56, 0x9d, 0xbc, 0x58, 0xad, 0xa5, 0x6c, 0xe8, 0xc5, 0x7d, 0x65, 0x4c, 0x09, + 0x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ab, 0x77, 0xad, 0x47, 0x7f, 0xbf, 0x6b, 0x3d, 0xfa, 0xf9, 0xba, 0x65, 0x5d, + 0x5d, 0xb7, 0xac, 0x3f, 0xaf, 0x5b, 0xd6, 0xbf, 0xd7, 0x2d, 0xeb, 0xa4, 0xac, 0x90, 0x2f, 0xff, + 0x0b, 0x00, 0x00, 0xff, 0xff, 0xa8, 0x64, 0xea, 0xc1, 0x10, 0x0d, 0x00, 0x00, } diff --git a/api/services/shim/shim.proto b/api/services/shim/shim.proto index 94f859dfd..b6aefba20 100644 --- a/api/services/shim/shim.proto +++ b/api/services/shim/shim.proto @@ -97,6 +97,10 @@ message StateResponse { uint32 pid = 3; containerd.v1.types.Status status = 4; repeated containerd.v1.types.Process processes = 5; + string stdin = 6; + string stdout = 7; + string stderr = 8; + bool terminal = 9; } message PauseRequest { diff --git a/api/types/task/task.pb.go b/api/types/task/task.pb.go index cb8775ef4..be43ffd57 100644 --- a/api/types/task/task.pb.go +++ b/api/types/task/task.pb.go @@ -113,6 +113,10 @@ type Task struct { Pid uint32 `protobuf:"varint,3,opt,name=pid,proto3" json:"pid,omitempty"` Status Status `protobuf:"varint,4,opt,name=status,proto3,enum=containerd.v1.types.Status" json:"status,omitempty"` Spec *google_protobuf1.Any `protobuf:"bytes,5,opt,name=spec" json:"spec,omitempty"` + Stdin string `protobuf:"bytes,6,opt,name=stdin,proto3" json:"stdin,omitempty"` + Stdout string `protobuf:"bytes,7,opt,name=stdout,proto3" json:"stdout,omitempty"` + Stderr string `protobuf:"bytes,8,opt,name=stderr,proto3" json:"stderr,omitempty"` + Terminal bool `protobuf:"varint,9,opt,name=terminal,proto3" json:"terminal,omitempty"` } func (m *Task) Reset() { *m = Task{} } @@ -129,6 +133,9 @@ type Process struct { ExitStatus uint32 `protobuf:"varint,7,opt,name=exit_status,json=exitStatus,proto3" json:"exit_status,omitempty"` Status Status `protobuf:"varint,8,opt,name=status,proto3,enum=containerd.v1.types.Status" json:"status,omitempty"` RuntimeData *google_protobuf1.Any `protobuf:"bytes,9,opt,name=runtime_data,json=runtimeData" json:"runtime_data,omitempty"` + Stdin string `protobuf:"bytes,10,opt,name=stdin,proto3" json:"stdin,omitempty"` + Stdout string `protobuf:"bytes,11,opt,name=stdout,proto3" json:"stdout,omitempty"` + Stderr string `protobuf:"bytes,12,opt,name=stderr,proto3" json:"stderr,omitempty"` } func (m *Process) Reset() { *m = Process{} } @@ -212,6 +219,34 @@ func (m *Task) MarshalTo(dAtA []byte) (int, error) { } i += n1 } + if len(m.Stdin) > 0 { + dAtA[i] = 0x32 + i++ + i = encodeVarintTask(dAtA, i, uint64(len(m.Stdin))) + i += copy(dAtA[i:], m.Stdin) + } + if len(m.Stdout) > 0 { + dAtA[i] = 0x3a + i++ + i = encodeVarintTask(dAtA, i, uint64(len(m.Stdout))) + i += copy(dAtA[i:], m.Stdout) + } + if len(m.Stderr) > 0 { + dAtA[i] = 0x42 + i++ + i = encodeVarintTask(dAtA, i, uint64(len(m.Stderr))) + i += copy(dAtA[i:], m.Stderr) + } + if m.Terminal { + dAtA[i] = 0x48 + i++ + if m.Terminal { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i++ + } return i, nil } @@ -311,6 +346,24 @@ func (m *Process) MarshalTo(dAtA []byte) (int, error) { } i += n3 } + if len(m.Stdin) > 0 { + dAtA[i] = 0x52 + i++ + i = encodeVarintTask(dAtA, i, uint64(len(m.Stdin))) + i += copy(dAtA[i:], m.Stdin) + } + if len(m.Stdout) > 0 { + dAtA[i] = 0x5a + i++ + i = encodeVarintTask(dAtA, i, uint64(len(m.Stdout))) + i += copy(dAtA[i:], m.Stdout) + } + if len(m.Stderr) > 0 { + dAtA[i] = 0x62 + i++ + i = encodeVarintTask(dAtA, i, uint64(len(m.Stderr))) + i += copy(dAtA[i:], m.Stderr) + } return i, nil } @@ -454,6 +507,21 @@ func (m *Task) Size() (n int) { l = m.Spec.Size() n += 1 + l + sovTask(uint64(l)) } + l = len(m.Stdin) + if l > 0 { + n += 1 + l + sovTask(uint64(l)) + } + l = len(m.Stdout) + if l > 0 { + n += 1 + l + sovTask(uint64(l)) + } + l = len(m.Stderr) + if l > 0 { + n += 1 + l + sovTask(uint64(l)) + } + if m.Terminal { + n += 2 + } return n } @@ -496,6 +564,18 @@ func (m *Process) Size() (n int) { l = m.RuntimeData.Size() n += 1 + l + sovTask(uint64(l)) } + l = len(m.Stdin) + if l > 0 { + n += 1 + l + sovTask(uint64(l)) + } + l = len(m.Stdout) + if l > 0 { + n += 1 + l + sovTask(uint64(l)) + } + l = len(m.Stderr) + if l > 0 { + n += 1 + l + sovTask(uint64(l)) + } return n } @@ -562,6 +642,10 @@ func (this *Task) String() string { `Pid:` + fmt.Sprintf("%v", this.Pid) + `,`, `Status:` + fmt.Sprintf("%v", this.Status) + `,`, `Spec:` + strings.Replace(fmt.Sprintf("%v", this.Spec), "Any", "google_protobuf1.Any", 1) + `,`, + `Stdin:` + fmt.Sprintf("%v", this.Stdin) + `,`, + `Stdout:` + fmt.Sprintf("%v", this.Stdout) + `,`, + `Stderr:` + fmt.Sprintf("%v", this.Stderr) + `,`, + `Terminal:` + fmt.Sprintf("%v", this.Terminal) + `,`, `}`, }, "") return s @@ -580,6 +664,9 @@ func (this *Process) String() string { `ExitStatus:` + fmt.Sprintf("%v", this.ExitStatus) + `,`, `Status:` + fmt.Sprintf("%v", this.Status) + `,`, `RuntimeData:` + strings.Replace(fmt.Sprintf("%v", this.RuntimeData), "Any", "google_protobuf1.Any", 1) + `,`, + `Stdin:` + fmt.Sprintf("%v", this.Stdin) + `,`, + `Stdout:` + fmt.Sprintf("%v", this.Stdout) + `,`, + `Stderr:` + fmt.Sprintf("%v", this.Stderr) + `,`, `}`, }, "") return s @@ -776,6 +863,113 @@ func (m *Task) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Stdin", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTask + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTask + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Stdin = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Stdout", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTask + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTask + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Stdout = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Stderr", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTask + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTask + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Stderr = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Terminal", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTask + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + m.Terminal = bool(v != 0) default: iNdEx = preIndex skippy, err := skipTask(dAtA[iNdEx:]) @@ -1056,6 +1250,93 @@ func (m *Process) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Stdin", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTask + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTask + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Stdin = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 11: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Stdout", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTask + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTask + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Stdout = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 12: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Stderr", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTask + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTask + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Stderr = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTask(dAtA[iNdEx:]) @@ -1503,50 +1784,54 @@ func init() { } var fileDescriptorTask = []byte{ - // 718 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0xbf, 0x6f, 0xf3, 0x44, - 0x18, 0xce, 0x39, 0xce, 0xaf, 0x4b, 0x93, 0xcf, 0x1c, 0x9f, 0x90, 0xbf, 0x80, 0x1c, 0x2b, 0x42, - 0x22, 0x42, 0xc2, 0x11, 0xe9, 0x00, 0x62, 0x4b, 0x63, 0xab, 0x8a, 0x10, 0x49, 0xb8, 0x38, 0xa2, - 0x5b, 0x74, 0xcd, 0x1d, 0xe6, 0xd4, 0xc6, 0xb6, 0xec, 0x73, 0x4b, 0x36, 0x46, 0xd4, 0x89, 0x7f, - 0xa0, 0x0b, 0xb0, 0xb2, 0x32, 0xb0, 0xb2, 0x74, 0x64, 0x64, 0x2a, 0x34, 0x7f, 0x09, 0xf2, 0xd9, - 0xf9, 0xa1, 0x36, 0x20, 0x16, 0xeb, 0xbd, 0xf7, 0x79, 0xee, 0xbd, 0xe7, 0x79, 0xee, 0x0c, 0x3f, - 0xf3, 0xb8, 0xf8, 0x26, 0xb9, 0xb4, 0x96, 0xc1, 0xaa, 0xb7, 0x0c, 0x7c, 0x41, 0xb8, 0xcf, 0x22, - 0x7a, 0x58, 0x92, 0x90, 0xf7, 0xc4, 0x3a, 0x64, 0x71, 0x4f, 0x90, 0xf8, 0x4a, 0x7e, 0xac, 0x30, - 0x0a, 0x44, 0x80, 0xde, 0xde, 0xb3, 0xac, 0x9b, 0x8f, 0x2d, 0x49, 0x6a, 0xbd, 0xf6, 0x02, 0x2f, - 0x90, 0x78, 0x2f, 0xad, 0x32, 0x6a, 0xeb, 0x8d,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 0x8d, 0x01, 0x2e, 0xcb, 0x32, 0xcd, 0xd3, - 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x51, 0xea, 0x99, 0x62, 0xee, 0x04, 0x00, 0x00, + // 775 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0x4d, 0x6f, 0xe3, 0x44, + 0x18, 0x8e, 0x1d, 0xe7, 0x6b, 0xd2, 0x66, 0xcd, 0x50, 0xad, 0xbc, 0x01, 0x39, 0x56, 0x84, 0x44, + 0x84, 0x84, 0x23, 0xb2, 0x07, 0x10, 0xb7, 0xb4, 0xb6, 0x56, 0x11, 0x22, 0x0d, 0x13, 0x47, 0xec, + 0x2d, 0x9a, 0x66, 0x06, 0x33, 0x6a, 0x3b, 0xb6, 0x3c, 0xe3, 0x2e, 0xbd, 0x71, 0x44, 0x7b, 0xe2, + 0x0f, 0xec, 0x85, 0x8f, 0xbf, 0xc0, 0x81, 0x5f, 0xd0, 0x23, 0x47, 0x4e, 0x85, 0xcd, 0x5f, 0xe0, + 0x0f, 0xa0, 0x19, 0xbb, 0x49, 0x76, 0x9b, 0x4a, 0x7b, 0xb1, 0xde, 0x79, 0x9f, 0x67, 0x26, 0xcf, + 0xfb, 0x3c, 0x6f, 0xc0, 0x97, 0x31, 0x93, 0xdf, 0xe7, 0x67, 0xfe, 0x2a, 0xb9, 0x1c, 0xae, 0x12, + 0x2e, 0x31, 0xe3, 0x34, 0x23, 0xbb, 0x25, 0x4e, 0xd9, 0x50, 0x5e, 0xa7, 0x54, 0x0c, 0x25, 0x16, + 0xe7, 0xfa, 0xe3, 0xa7, 0x59, 0x22, 0x13, 0xf8, 0xfe, 0x96, 0xe5, 0x5f, 0x7d, 0xe6, 0x6b, 0x52, + 0xf7, 0x28, 0x4e, 0xe2, 0x44, 0xe3, 0x43, 0x55, 0x15, 0xd4, 0xee, 0x93, 0x38, 0x49, 0xe2, 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25, 0xf0, 0xc3, 0x8d, 0x2c, 0xab, 0x6b, 0xbf, 0x7c, 0xe5, 0x1d, 0x14, 0xf0, 0x0c, 0xe7, 0x82, + 0x92, 0x6e, 0xe7, 0xa7, 0x5f, 0xdd, 0xca, 0x9f, 0xbf, 0xb9, 0xa5, 0xda, 0x63, 0xe7, 0xe6, 0xb5, + 0x5b, 0xf9, 0xfb, 0xb5, 0x5b, 0xf9, 0x71, 0xed, 0x1a, 0x37, 0x6b, 0xd7, 0xf8, 0x6b, 0xed, 0x1a, + 0xff, 0xae, 0x5d, 0xe3, 0xac, 0xae, 0xdd, 0x7c, 0xfa, 0x7f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x48, + 0xcc, 0xfd, 0x9a, 0x96, 0x05, 0x00, 0x00, } diff --git a/api/types/task/task.proto b/api/types/task/task.proto index cce329f8e..e7563200e 100644 --- a/api/types/task/task.proto +++ b/api/types/task/task.proto @@ -23,6 +23,10 @@ message Task { uint32 pid = 3; Status status = 4; google.protobuf.Any spec = 5; + string stdin = 6; + string stdout = 7; + string stderr = 8; + bool terminal = 9; } message Process { @@ -35,6 +39,9 @@ message Process { uint32 exit_status = 7; Status status = 8; google.protobuf.Any runtime_data = 9; + string stdin = 10; + string stdout = 11; + string stderr = 12; } message User { diff --git a/container.go b/container.go index 1deec2602..71c408228 100644 --- a/container.go +++ b/container.go @@ -3,6 +3,7 @@ package containerd import ( "context" "encoding/json" + "path/filepath" "github.com/containerd/containerd/api/services/containers" "github.com/containerd/containerd/api/services/execution" @@ -16,7 +17,7 @@ type Container interface { NewTask(context.Context, IOCreation) (Task, error) Spec() (*specs.Spec, error) Task() Task - LoadTask(context.Context, IOCreation) (Task, error) + LoadTask(context.Context, IOAttach) (Task, error) } func containerFromProto(client *Client, c containers.Container) *container { @@ -110,17 +111,28 @@ func (c *container) NewTask(ctx context.Context, ioCreate IOCreation) (Task, err return t, nil } -func (c *container) LoadTask(ctx context.Context, ioCreate IOCreation) (Task, error) { - i, err := ioCreate() - if err != nil { - return nil, err - } +func (c *container) LoadTask(ctx context.Context, ioAttach IOAttach) (Task, error) { response, err := c.client.TaskService().Info(ctx, &execution.InfoRequest{ ContainerID: c.c.ID, }) if err != nil { return nil, err } + // get the existing fifo paths from the task information stored by the daemon + paths := &FifoSet{ + Dir: getFifoDir([]string{ + response.Task.Stdin, + response.Task.Stdout, + response.Task.Stderr, + }), + In: response.Task.Stdin, + Out: response.Task.Stdout, + Err: response.Task.Stderr, + } + i, err := ioAttach(paths) + if err != nil { + return nil, err + } t := &task{ client: c.client, io: i, @@ -130,3 +142,14 @@ func (c *container) LoadTask(ctx context.Context, ioCreate IOCreation) (Task, er c.task = t return t, nil } + +// getFifoDir looks for any non-empty path for a stdio fifo +// and returns the dir for where it is located +func getFifoDir(paths []string) string { + for _, p := range paths { + if p != "" { + return filepath.Dir(p) + } + } + return "" +} diff --git a/container_test.go b/container_test.go index f2e791072..644334ad9 100644 --- a/container_test.go +++ b/container_test.go @@ -502,13 +502,7 @@ func TestContainerAttach(t *testing.T) { wg.Done() }() - // TODO: return fifo information from shim based on task/process - dir, err := ioutil.TempDir("", "attach") - if err != nil { - t.Error(err) - return - } - task, err := container.NewTask(ctx, WithIO(r, ow, ioutil.Discard, dir)) + task, err := container.NewTask(ctx, NewIO(r, ow, ioutil.Discard)) if err != nil { t.Error(err) return @@ -546,7 +540,7 @@ func TestContainerAttach(t *testing.T) { t.Error(err) return } - if task, err = container.LoadTask(ctx, WithIO(r, ow, ioutil.Discard, dir)); err != nil { + if task, err = container.LoadTask(ctx, WithAttach(r, ow, ioutil.Discard)); err != nil { t.Error(err) return } diff --git a/io.go b/io.go index e8c9f817c..a1b22e3b6 100644 --- a/io.go +++ b/io.go @@ -1,6 +1,7 @@ package containerd import ( + "fmt" "io" "io/ioutil" "os" @@ -26,6 +27,8 @@ func (i *IO) Close() error { type IOCreation func() (*IO, error) +type IOAttach func(*FifoSet) (*IO, error) + func NewIO(stdin io.Reader, stdout, stderr io.Writer) IOCreation { return func() (*IO, error) { paths, err := NewFifos() @@ -52,11 +55,10 @@ func NewIO(stdin io.Reader, stdout, stderr io.Writer) IOCreation { } } -func WithIO(stdin io.Reader, stdout, stderr io.Writer, dir string) IOCreation { - return func() (*IO, error) { - paths, err := WithFifos(dir) - if err != nil { - return nil, err +func WithAttach(stdin io.Reader, stdout, stderr io.Writer) IOAttach { + return func(paths *FifoSet) (*IO, error) { + if paths == nil { + return nil, fmt.Errorf("cannot attach to existing fifos") } i := &IO{ Terminal: false, @@ -121,19 +123,6 @@ func NewFifos() (*FifoSet, error) { }, nil } -// WithFifos returns existing or creates new fifos inside an existing dir -func WithFifos(dir string) (*FifoSet, error) { - if err := os.MkdirAll(dir, 0700); err != nil { - return nil, err - } - return &FifoSet{ - Dir: dir, - In: filepath.Join(dir, "stdin"), - Out: filepath.Join(dir, "stdout"), - Err: filepath.Join(dir, "stderr"), - }, nil -} - type FifoSet struct { // Dir is the directory holding the task fifos Dir string diff --git a/linux/shim/exec.go b/linux/shim/exec.go index 72703677b..39e2b3aeb 100644 --- a/linux/shim/exec.go +++ b/linux/shim/exec.go @@ -35,12 +35,21 @@ type execProcess struct { stdin io.Closer parent *initProcess + + stdinPath string + stdoutPath string + stderrPath string + terminal bool } func newExecProcess(context context.Context, path string, r *shimapi.ExecRequest, parent *initProcess, id int) (process, error) { e := &execProcess{ - id: id, - parent: parent, + id: id, + parent: parent, + stdinPath: r.Stdin, + stdoutPath: r.Stdout, + stderrPath: r.Stderr, + terminal: r.Terminal, } var ( err error diff --git a/linux/shim/init.go b/linux/shim/init.go index 0bf538a71..1f8ed3047 100644 --- a/linux/shim/init.go +++ b/linux/shim/init.go @@ -30,7 +30,8 @@ type initProcess struct { // the right order when invoked in separate go routines. // This is the case within the shim implementation as it makes use of // the reaper interface. - mu sync.Mutex + mu sync.Mutex + id string bundle string console console.Console @@ -41,6 +42,11 @@ type initProcess struct { pid int closers []io.Closer stdin io.Closer + + stdinPath string + stdoutPath string + stderrPath string + terminal bool } func newInitProcess(context context.Context, path string, r *shimapi.CreateRequest) (*initProcess, error) { @@ -61,9 +67,13 @@ func newInitProcess(context context.Context, path string, r *shimapi.CreateReque PdeathSignal: syscall.SIGKILL, } p := &initProcess{ - id: r.ID, - bundle: r.Bundle, - runc: runtime, + id: r.ID, + bundle: r.Bundle, + runc: runtime, + stdinPath: r.Stdin, + stdoutPath: r.Stdout, + stderrPath: r.Stderr, + terminal: r.Terminal, } var ( err error diff --git a/linux/shim/service.go b/linux/shim/service.go index cb03d23fb..3983f6f7a 100644 --- a/linux/shim/service.go +++ b/linux/shim/service.go @@ -192,6 +192,9 @@ func (s *Service) State(ctx context.Context, r *shimapi.StateRequest) (*shimapi. Pid: uint32(s.initProcess.Pid()), Status: status, Processes: []*task.Process{}, + Stdin: s.initProcess.stdinPath, + Stdout: s.initProcess.stdoutPath, + Stderr: s.initProcess.stderrPath, } s.mu.Lock() defer s.mu.Unlock() @@ -203,10 +206,16 @@ func (s *Service) State(ctx context.Context, r *shimapi.StateRequest) (*shimapi. } status = task.StatusStopped } - o.Processes = append(o.Processes, &task.Process{ + pp := &task.Process{ Pid: uint32(p.Pid()), Status: status, - }) + } + if ep, ok := p.(*execProcess); ok { + pp.Stdin = ep.stdinPath + pp.Stdout = ep.stdoutPath + pp.Stderr = ep.stderrPath + } + o.Processes = append(o.Processes, pp) } return o, nil } @@ -270,7 +279,6 @@ func (s *Service) Processes(ctx context.Context, r *shimapi.ProcessesRequest) (* if err != nil { return nil, err } - ps := []*task.Process{} for _, pid := range pids { ps = append(ps, &task.Process{ @@ -280,9 +288,7 @@ func (s *Service) Processes(ctx context.Context, r *shimapi.ProcessesRequest) (* resp := &shimapi.ProcessesResponse{ Processes: ps, } - return resp, nil - } func (s *Service) CloseStdin(ctx context.Context, r *shimapi.CloseStdinRequest) (*google_protobuf.Empty, error) { diff --git a/linux/task.go b/linux/task.go index dd0de51f6..1a04033a4 100644 --- a/linux/task.go +++ b/linux/task.go @@ -12,19 +12,6 @@ import ( specs "github.com/opencontainers/runtime-spec/specs-go" ) -type State struct { - pid uint32 - status plugin.Status -} - -func (s State) Pid() uint32 { - return s.pid -} - -func (s State) Status() plugin.Status { - return s.status -} - type Task struct { containerID string spec []byte @@ -56,7 +43,7 @@ func (c *Task) Start(ctx context.Context) error { func (c *Task) State(ctx context.Context) (plugin.State, error) { response, err := c.shim.State(ctx, &shim.StateRequest{}) if err != nil { - return nil, err + return plugin.State{}, err } var status plugin.Status switch response.Status { @@ -70,9 +57,13 @@ func (c *Task) State(ctx context.Context) (plugin.State, error) { status = plugin.PausedStatus // TODO: containerd.DeletedStatus } - return &State{ - pid: response.Pid, - status: status, + return plugin.State{ + Pid: response.Pid, + Status: status, + Stdin: response.Stdin, + Stdout: response.Stdout, + Stderr: response.Stderr, + Terminal: response.Terminal, }, nil } @@ -181,8 +172,8 @@ func (p *Process) State(ctx context.Context) (plugin.State, error) { // use the container status for the status of the process state, err := p.c.State(ctx) if err != nil { - return nil, err + return state, err } - state.(*State).pid = uint32(p.pid) + state.Pid = uint32(p.pid) return state, nil } diff --git a/metrics/cgroups/cgroups.go b/metrics/cgroups/cgroups.go index ab3009893..1fb3ea373 100644 --- a/metrics/cgroups/cgroups.go +++ b/metrics/cgroups/cgroups.go @@ -51,7 +51,7 @@ func (m *cgroupsMonitor) Monitor(c plugin.Task) error { if err != nil { return err } - cg, err := cgroups.Load(cgroups.V1, cgroups.PidPath(int(state.Pid()))) + cg, err := cgroups.Load(cgroups.V1, cgroups.PidPath(int(state.Pid))) if err != nil { return err } diff --git a/plugin/container.go b/plugin/container.go index 2d2145a5a..5c013623c 100644 --- a/plugin/container.go +++ b/plugin/container.go @@ -71,9 +71,13 @@ const ( PausedStatus ) -type State interface { +type State struct { // Status is the current status of the container - Status() Status + Status Status // Pid is the main process id for the container - Pid() uint32 + Pid uint32 + Stdin string + Stdout string + Stderr string + Terminal bool } diff --git a/services/execution/service.go b/services/execution/service.go index e944dd412..dacad40de 100644 --- a/services/execution/service.go +++ b/services/execution/service.go @@ -164,7 +164,7 @@ func (s *Service) Create(ctx context.Context, r *api.CreateRequest) (*api.Create } return &api.CreateResponse{ ContainerID: r.ContainerID, - Pid: state.Pid(), + Pid: state.Pid, }, nil } @@ -208,7 +208,7 @@ func taskFromContainerd(ctx context.Context, c plugin.Task) (*task.Task, error) } var status task.Status - switch state.Status() { + switch state.Status { case plugin.CreatedStatus: status = task.StatusCreated case plugin.RunningStatus: @@ -218,17 +218,21 @@ func taskFromContainerd(ctx context.Context, c plugin.Task) (*task.Task, error) case plugin.PausedStatus: status = task.StatusPaused default: - log.G(ctx).WithField("status", state.Status()).Warn("unknown status") + log.G(ctx).WithField("status", state.Status).Warn("unknown status") } return &task.Task{ ID: c.Info().ID, ContainerID: c.Info().ContainerID, - Pid: state.Pid(), + Pid: state.Pid, Status: status, Spec: &protobuf.Any{ TypeUrl: specs.Version, Value: c.Info().Spec, }, + Stdin: state.Stdin, + Stdout: state.Stdout, + Stderr: state.Stderr, + Terminal: state.Terminal, }, nil } @@ -359,7 +363,7 @@ func (s *Service) Exec(ctx context.Context, r *api.ExecRequest) (*api.ExecRespon return nil, err } return &api.ExecResponse{ - Pid: state.Pid(), + Pid: state.Pid, }, nil } diff --git a/windows/container.go b/windows/container.go index 0afed30e0..06232e73c 100644 --- a/windows/container.go +++ b/windows/container.go @@ -116,7 +116,10 @@ func (c *container) Resume(ctx context.Context) error { } func (c *container) State(ctx context.Context) (plugin.State, error) { - return c, nil + return plugin.State{ + Pid: c.Pid(), + Status: c.Status(), + }, nil } func (c *container) Kill(ctx context.Context, signal uint32, pid uint32, all bool) error { diff --git a/windows/process.go b/windows/process.go index 438eea56d..adf9b7a8d 100644 --- a/windows/process.go +++ b/windows/process.go @@ -15,7 +15,10 @@ type process struct { } func (p *process) State(ctx context.Context) (plugin.State, error) { - return p, nil + return plugin.State{ + Pid: p.Pid(), + Status: p.Status(), + }, nil } func (p *process) Kill(ctx context.Context, sig uint32, all bool) error { From e022cf3ad0609c800c3d60feeaaaa916e127225a Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Thu, 1 Jun 2017 13:53:54 -0700 Subject: [PATCH 5/6] Add Resize pty support to client Signed-off-by: Michael Crosby --- process.go | 14 ++++++++++++++ task.go | 13 +++++++++++++ 2 files changed, 27 insertions(+) diff --git a/process.go b/process.go index 3f6edcd0d..f98304fee 100644 --- a/process.go +++ b/process.go @@ -96,3 +96,17 @@ func (p *process) CloseStdin(ctx context.Context) error { }) return err } + +func (p *process) IO() *IO { + return p.io +} + +func (p *process) Resize(ctx context.Context, w, h uint32) error { + _, err := p.task.client.TaskService().Pty(ctx, &execution.PtyRequest{ + ContainerID: p.task.containerID, + Width: w, + Height: h, + Pid: p.pid, + }) + return err +} diff --git a/task.go b/task.go index 21bf92a3f..ead1ea6c0 100644 --- a/task.go +++ b/task.go @@ -33,6 +33,7 @@ type Task interface { Exec(context.Context, *specs.Process, IOCreation) (Process, error) Processes(context.Context) ([]uint32, error) CloseStdin(context.Context) error + Resize(ctx context.Context, w, h uint32) error IO() *IO } @@ -42,6 +43,8 @@ type Process interface { Kill(context.Context, syscall.Signal) error Wait(context.Context) (uint32, error) CloseStdin(context.Context) error + Resize(ctx context.Context, w, h uint32) error + IO() *IO } var _ = (Task)(&task{}) @@ -173,3 +176,13 @@ func (t *task) CloseStdin(ctx context.Context) error { func (t *task) IO() *IO { return t.io } + +func (t *task) Resize(ctx context.Context, w, h uint32) error { + _, err := t.client.TaskService().Pty(ctx, &execution.PtyRequest{ + ContainerID: t.containerID, + Width: w, + Height: h, + Pid: t.pid, + }) + return err +} From 887a14941738bcab2535307c0aaa260e4d34487d Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Thu, 1 Jun 2017 14:46:14 -0700 Subject: [PATCH 6/6] Add terminal support Signed-off-by: Michael Crosby --- container.go | 7 ++++--- io.go | 40 ++++++++++++++++------------------------ 2 files changed, 20 insertions(+), 27 deletions(-) diff --git a/container.go b/container.go index 71c408228..7a587b647 100644 --- a/container.go +++ b/container.go @@ -125,9 +125,10 @@ func (c *container) LoadTask(ctx context.Context, ioAttach IOAttach) (Task, erro response.Task.Stdout, response.Task.Stderr, }), - In: response.Task.Stdin, - Out: response.Task.Stdout, - Err: response.Task.Stderr, + In: response.Task.Stdin, + Out: response.Task.Stdout, + Err: response.Task.Stderr, + Terminal: response.Task.Terminal, } i, err := ioAttach(paths) if err != nil { diff --git a/io.go b/io.go index a1b22e3b6..e3c56d909 100644 --- a/io.go +++ b/io.go @@ -30,13 +30,17 @@ type IOCreation func() (*IO, error) type IOAttach func(*FifoSet) (*IO, error) func NewIO(stdin io.Reader, stdout, stderr io.Writer) IOCreation { + return NewIOWithTerminal(stdin, stdout, stderr, false) +} + +func NewIOWithTerminal(stdin io.Reader, stdout, stderr io.Writer, terminal bool) IOCreation { return func() (*IO, error) { paths, err := NewFifos() if err != nil { return nil, err } i := &IO{ - Terminal: false, + Terminal: terminal, Stdout: paths.Out, Stderr: paths.Err, Stdin: paths.In, @@ -46,13 +50,14 @@ func NewIO(stdin io.Reader, stdout, stderr io.Writer) IOCreation { out: stdout, err: stderr, } - closer, err := copyIO(paths, set, false) + closer, err := copyIO(paths, set, i.Terminal) if err != nil { return nil, err } i.closer = closer return i, nil } + } func WithAttach(stdin io.Reader, stdout, stderr io.Writer) IOAttach { @@ -61,7 +66,7 @@ func WithAttach(stdin io.Reader, stdout, stderr io.Writer) IOAttach { return nil, fmt.Errorf("cannot attach to existing fifos") } i := &IO{ - Terminal: false, + Terminal: paths.Terminal, Stdout: paths.Out, Stderr: paths.Err, Stdin: paths.In, @@ -71,7 +76,7 @@ func WithAttach(stdin io.Reader, stdout, stderr io.Writer) IOAttach { out: stdout, err: stderr, } - closer, err := copyIO(paths, set, false) + closer, err := copyIO(paths, set, i.Terminal) if err != nil { return nil, err } @@ -83,26 +88,12 @@ func WithAttach(stdin io.Reader, stdout, stderr io.Writer) IOAttach { // Stdio returns an IO implementation to be used for a task // that outputs the container's IO as the current processes Stdio func Stdio() (*IO, error) { - paths, err := NewFifos() - if err != nil { - return nil, err - } - set := &ioSet{ - in: os.Stdin, - out: os.Stdout, - err: os.Stderr, - } - closer, err := copyIO(paths, set, false) - if err != nil { - return nil, err - } - return &IO{ - Terminal: false, - Stdin: paths.In, - Stdout: paths.Out, - Stderr: paths.Err, - closer: closer, - }, nil + return NewIO(os.Stdin, os.Stdout, os.Stderr)() +} + +// StdioTerminal will setup the IO for the task to use a terminal +func StdioTerminal() (*IO, error) { + return NewIOWithTerminal(os.Stdin, os.Stdout, os.Stderr, true)() } // NewFifos returns a new set of fifos for the task @@ -127,6 +118,7 @@ type FifoSet struct { // Dir is the directory holding the task fifos Dir string In, Out, Err string + Terminal bool } type ioSet struct {