diff --git a/api/grpc/server/server.go b/api/grpc/server/server.go index 3676ea2..876add0 100644 --- a/api/grpc/server/server.go +++ b/api/grpc/server/server.go @@ -34,6 +34,9 @@ func (s *apiServer) CreateContainer(ctx context.Context, c *types.CreateContaine e := supervisor.NewEvent(supervisor.StartContainerEventType) e.ID = c.Id e.BundlePath = c.BundlePath + e.Stdin = c.Stdin + e.Stdout = c.Stdout + e.Stderr = c.Stderr e.StartResponse = make(chan supervisor.StartResponse, 1) if c.Checkpoint != "" { e.Checkpoint = &runtime.Checkpoint{ @@ -44,12 +47,8 @@ func (s *apiServer) CreateContainer(ctx context.Context, c *types.CreateContaine if err := <-e.Err; err != nil { return nil, err } - sr := <-e.StartResponse - return &types.CreateContainerResponse{ - Stdin: sr.Stdin, - Stdout: sr.Stdout, - Stderr: sr.Stderr, - }, nil + <-e.StartResponse + return &types.CreateContainerResponse{}, nil } func (s *apiServer) Signal(ctx context.Context, r *types.SignalRequest) (*types.SignalResponse, error) { @@ -86,17 +85,16 @@ func (s *apiServer) AddProcess(ctx context.Context, r *types.AddProcessRequest) e.ID = r.Id e.Pid = r.Pid e.ProcessSpec = process + e.Stdin = r.Stdin + e.Stdout = r.Stdout + e.Stderr = r.Stderr e.StartResponse = make(chan supervisor.StartResponse, 1) s.sv.SendEvent(e) if err := <-e.Err; err != nil { return nil, err } - sr := <-e.StartResponse - return &types.AddProcessResponse{ - Stdin: sr.Stdin, - Stdout: sr.Stdout, - Stderr: sr.Stderr, - }, nil + <-e.StartResponse + return &types.AddProcessResponse{}, nil } func (s *apiServer) CreateCheckpoint(ctx context.Context, r *types.CreateCheckpointRequest) (*types.CreateCheckpointResponse, error) { diff --git a/api/grpc/types/api.pb.go b/api/grpc/types/api.pb.go index 56e2765..d6a47d4 100644 --- a/api/grpc/types/api.pb.go +++ b/api/grpc/types/api.pb.go @@ -88,7 +88,10 @@ func (*UpdateProcessResponse) Descriptor() ([]byte, []int) { return fileDescript type CreateContainerRequest struct { Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"` BundlePath string `protobuf:"bytes,2,opt,name=bundlePath" json:"bundlePath,omitempty"` - Checkpoint string `protobuf:"bytes,7,opt,name=checkpoint" json:"checkpoint,omitempty"` + Checkpoint string `protobuf:"bytes,3,opt,name=checkpoint" json:"checkpoint,omitempty"` + Stdin string `protobuf:"bytes,4,opt,name=stdin" json:"stdin,omitempty"` + Stdout string `protobuf:"bytes,5,opt,name=stdout" json:"stdout,omitempty"` + Stderr string `protobuf:"bytes,6,opt,name=stderr" json:"stderr,omitempty"` } func (m *CreateContainerRequest) Reset() { *m = CreateContainerRequest{} } @@ -97,10 +100,6 @@ func (*CreateContainerRequest) ProtoMessage() {} func (*CreateContainerRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} } type CreateContainerResponse struct { - Pid uint32 `protobuf:"varint,1,opt,name=pid" json:"pid,omitempty"` - Stdin string `protobuf:"bytes,2,opt,name=stdin" json:"stdin,omitempty"` - Stdout string `protobuf:"bytes,3,opt,name=stdout" json:"stdout,omitempty"` - Stderr string `protobuf:"bytes,4,opt,name=stderr" json:"stderr,omitempty"` } func (m *CreateContainerResponse) Reset() { *m = CreateContainerResponse{} } @@ -135,6 +134,9 @@ type AddProcessRequest struct { Env []string `protobuf:"bytes,5,rep,name=env" json:"env,omitempty"` Cwd string `protobuf:"bytes,6,opt,name=cwd" json:"cwd,omitempty"` Pid string `protobuf:"bytes,7,opt,name=pid" json:"pid,omitempty"` + Stdin string `protobuf:"bytes,8,opt,name=stdin" json:"stdin,omitempty"` + Stdout string `protobuf:"bytes,9,opt,name=stdout" json:"stdout,omitempty"` + Stderr string `protobuf:"bytes,10,opt,name=stderr" json:"stderr,omitempty"` } func (m *AddProcessRequest) Reset() { *m = AddProcessRequest{} } @@ -161,9 +163,6 @@ func (*User) ProtoMessage() {} func (*User) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{7} } type AddProcessResponse struct { - Stdin string `protobuf:"bytes,1,opt,name=stdin" json:"stdin,omitempty"` - Stdout string `protobuf:"bytes,2,opt,name=stdout" json:"stdout,omitempty"` - Stderr string `protobuf:"bytes,3,opt,name=stderr" json:"stderr,omitempty"` } func (m *AddProcessResponse) Reset() { *m = AddProcessResponse{} } @@ -1136,99 +1135,99 @@ var _API_serviceDesc = grpc.ServiceDesc{ } var fileDescriptor0 = []byte{ - // 1497 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xb4, 0x58, 0xdb, 0x72, 0xdc, 0x44, - 0x10, 0xf5, 0xde, 0x77, 0x7b, 0x2f, 0xb6, 0xe5, 0xdb, 0x7a, 0x43, 0x48, 0x10, 0x81, 0xa4, 0xa8, - 0x94, 0x2b, 0x38, 0x5c, 0x42, 0x78, 0x80, 0xe0, 0xa4, 0x12, 0xa8, 0x04, 0x5c, 0xb1, 0x4d, 0x15, - 0x2f, 0x6c, 0xc9, 0xd2, 0xb0, 0x3b, 0xac, 0x56, 0x12, 0xd2, 0xc8, 0x97, 0x47, 0x5e, 0x79, 0xe5, - 0x5f, 0xf8, 0x00, 0xbe, 0x80, 0xef, 0xe0, 0x2b, 0xe8, 0xb9, 0xae, 0xa4, 0xbd, 0x04, 0x1e, 0x78, - 0x71, 0xd5, 0xcc, 0x74, 0x9f, 0x3e, 0x7d, 0xba, 0x7b, 0x56, 0x63, 0x68, 0x39, 0x11, 0x3d, 0x88, - 0xe2, 0x90, 0x85, 0x56, 0x8d, 0x5d, 0x47, 0x24, 0xb1, 0xcf, 0x61, 0xfb, 0x2c, 0xf2, 0x1c, 0x46, - 0x8e, 0xe3, 0xd0, 0x25, 0x49, 0xf2, 0x9a, 0xfc, 0x92, 0x92, 0x84, 0x59, 0x00, 0x65, 0xea, 0xf5, - 0x4b, 0xb7, 0x4b, 0xf7, 0x5a, 0x56, 0x1b, 0x2a, 0x11, 0x2e, 0xca, 0x62, 0x81, 0x27, 0xae, 0x1f, - 0x26, 0xe4, 0x84, 0x79, 0x34, 0xe8, 0x57, 0x70, 0xaf, 0x69, 0x75, 0xa1, 0x76, 0x49, 0x3d, 0x36, - 0xee, 0x57, 0x71, 0xd9, 0xb5, 0x7a, 0x50, 0x1f, 0x13, 0x3a, 0x1a, 0xb3, 0x7e, 0x8d, 0xaf, 0xed, - 0x3d, 0xd8, 0x29, 0xc4, 0x48, 0xa2, 0x30, 0x48, 0x88, 0xfd, 0x12, 0x76, 0x8f, 0x62, 0x82, 0x07, - 0x47, 0x61, 0xc0, 0x1c, 0x1a, 0x90, 0x78, 0x51, 0x78, 0x5c, 0x9c, 0xa7, 0x81, 0xe7, 0x93, 0x63, - 0x07, 0x43, 0xcc, 0x58, 0x8c, 0x89, 0x3b, 0x89, 0x42, 0x1a, 0xb0, 0x7e, 0x83, 0xef, 0xd9, 0x67, - 0xb0, 0x37, 0x87, 0x26, 0x03, 0xe9, 0x0c, 0x4a, 0x82, 0x1e, 0xb2, 0x4d, 0x04, 0x79, 0x09, 0x85, - 0x6c, 0x71, 0x19, 0xa6, 0x4c, 0x24, 0xa3, 0xd7, 0x24, 0x8e, 0x45, 0x36, 0x2d, 0xfb, 0x11, 0x74, - 0x4f, 0xe8, 0x28, 0x70, 0xfc, 0x37, 0x4a, 0xc3, 0x3d, 0x85, 0xa5, 0x40, 0xea, 0xda, 0x1b, 0xd0, - 0xd3, 0x9e, 0x2a, 0xe1, 0x5f, 0x4b, 0xb0, 0xf9, 0xc4, 0xf3, 0x56, 0x68, 0xbd, 0x01, 0x4d, 0x46, - 0xe2, 0x29, 0xe5, 0x28, 0x65, 0x21, 0xee, 0x3e, 0x54, 0xd3, 0x84, 0xc4, 0x02, 0xb3, 0x7d, 0xd8, - 0x3e, 0x10, 0x75, 0x3b, 0x38, 0xc3, 0x2d, 0xab, 0x03, 0x55, 0x27, 0x1e, 0x25, 0x48, 0xb4, 0x22, - 0xb9, 0x90, 0xe0, 0x02, 0x35, 0x57, 0x0b, 0xf7, 0xd2, 0xeb, 0xd7, 0x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c, 0xe0, - 0xe6, 0x92, 0x53, 0x03, 0xf8, 0x91, 0x1c, 0x04, 0xfc, 0x72, 0xd1, 0x35, 0xcb, 0xbc, 0x29, 0x06, - 0xdb, 0xf9, 0x4d, 0xe3, 0xf5, 0x00, 0xea, 0xf2, 0x7b, 0xd4, 0x34, 0x40, 0xee, 0xf3, 0x74, 0xd0, - 0xc9, 0xee, 0xda, 0x6b, 0x0f, 0x4a, 0x78, 0xe7, 0x35, 0x9f, 0x13, 0x26, 0xa7, 0x23, 0x1b, 0x6a, - 0xce, 0x45, 0x6c, 0x72, 0x97, 0xf3, 0xba, 0xf8, 0xe7, 0xc6, 0xc3, 0x7f, 0x02, 0x00, 0x00, 0xff, - 0xff, 0xb2, 0xd2, 0x28, 0x97, 0xe9, 0x10, 0x00, 0x00, + // 1493 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xb4, 0x58, 0xd9, 0x72, 0x1b, 0x45, + 0x17, 0xb6, 0xa4, 0xd1, 0x76, 0xb4, 0xd8, 0x1e, 0x2f, 0x91, 0x95, 0x3f, 0x7f, 0xc2, 0x10, 0x48, + 0x8a, 0x4a, 0xb9, 0x82, 0xc3, 0x12, 0xc2, 0x05, 0x04, 0x27, 0x95, 0x40, 0x25, 0xe0, 0x8a, 0x6d, + 0xaa, 0xb8, 0x41, 0x35, 0x9e, 0x69, 0xa4, 0x46, 0xa3, 0x99, 0x61, 0xa6, 0xc7, 0x4b, 0xf1, 0x06, + 0xdc, 0xf2, 0x22, 0x5c, 0xf1, 0x00, 0x3c, 0x01, 0xcf, 0xc1, 0x53, 0x70, 0x7a, 0x9b, 0x4d, 0x8b, + 0xe1, 0x82, 0x1b, 0x55, 0x75, 0xf7, 0x59, 0xbe, 0xf3, 0x9d, 0x65, 0xba, 0x05, 0x6d, 0x3b, 0xa4, + 0xfb, 0x61, 0x14, 0xb0, 0xc0, 0xac, 0xb3, 0xab, 0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, + 0x52, 0x15, 0x7c, 0xee, 0x81, 0x91, 0xc4, 0x24, 0x12, 0x36, 0x3b, 0x07, 0x9d, 0x7d, 0x91, 0xaa, + 0xfd, 0x53, 0xdc, 0x32, 0xbb, 0x60, 0xd8, 0xd1, 0x38, 0xc6, 0x18, 0x6b, 0x12, 0x0b, 0xf1, 0xcf, + 0x31, 0x40, 0xb5, 0x70, 0x2e, 0x5c, 0x19, 0x9d, 0x46, 0xd9, 0x2c, 0x32, 0xd3, 0x2a, 0x31, 0xd3, + 0x2e, 0x31, 0x03, 0x82, 0x99, 0xc7, 0x60, 0x08, 0x5f, 0x68, 0x23, 0x51, 0x28, 0x7b, 0x7c, 0x31, + 0x56, 0x61, 0xf7, 0xcc, 0x5d, 0xe8, 0xdb, 0xae, 0x4b, 0x19, 0x0d, 0x10, 0xf4, 0x0b, 0xea, 0xc6, + 0x08, 0xb5, 0x86, 0xe1, 0x6f, 0x83, 0x99, 0x8f, 0x55, 0x51, 0xf0, 0x2a, 0x65, 0x3a, 0x4d, 0xd9, + 0x22, 0x1e, 0xde, 0x29, 0xe4, 0xb4, 0x2a, 0x62, 0xdf, 0x54, 0xb1, 0x67, 0x9a, 0xd6, 0x10, 0x06, + 0xf3, 0xd6, 0x94, 0xa7, 0x47, 0x70, 0xe3, 0x19, 0xf1, 0xc8, 0x75, 0x9e, 0x90, 0x44, 0xdf, 0x9e, + 0x11, 0x99, 0x43, 0x6e, 0x70, 0x5e, 0x49, 0x19, 0x7c, 0x1b, 0x76, 0x5e, 0xd1, 0x98, 0xad, 0x34, + 0x67, 0x7d, 0x07, 0x90, 0x09, 0xa4, 0xc6, 0x53, 0x57, 0xe4, 0x92, 0x32, 0x95, 0x58, 0x24, 0x91, + 0x39, 0xa1, 0xea, 0x9a, 0x2d, 0xe8, 0x24, 0x3e, 0xbd, 0x3c, 0x0e, 0x9c, 0x29, 0x61, 0xb1, 0xa8, + 0x5a, 0xd1, 0x4a, 0xf1, 0x84, 0x78, 0x9e, 0x28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 0x98, 0x25, 0x56, 0xcb, 0x6f, 0x84, 0xe1, 0xed, 0xa5, 0xe7, + 0x79, 0xb3, 0xe5, 0xb7, 0x47, 0x6a, 0x76, 0xc9, 0x4b, 0x26, 0x35, 0xbb, 0xf4, 0xd1, 0xb2, 0x66, + 0x7e, 0x03, 0xfd, 0xe2, 0xb3, 0xc1, 0xd4, 0x24, 0x2d, 0x7c, 0xcd, 0x0c, 0x6f, 0x2d, 0x39, 0x4d, + 0x0d, 0x7e, 0x20, 0x1b, 0x01, 0x6f, 0x2e, 0x3a, 0x67, 0xb9, 0x37, 0xc5, 0x70, 0xbb, 0xb8, 0x99, + 0x6a, 0x3d, 0x84, 0x86, 0xbc, 0x8f, 0xa6, 0x05, 0x50, 0xb8, 0x9e, 0x0e, 0xbb, 0xf9, 0x5d, 0x6b, + 0xed, 0x61, 0x05, 0x67, 0x5e, 0xeb, 0x05, 0x61, 0xb2, 0x3b, 0xf2, 0xae, 0xe6, 0x54, 0xc4, 0x26, + 0x57, 0x39, 0x6b, 0x88, 0xff, 0x33, 0x1e, 0xfd, 0x1d, 0x00, 0x00, 0xff, 0xff, 0xe9, 0x8d, 0xe9, + 0x67, 0xdc, 0x10, 0x00, 0x00, } diff --git a/api/grpc/types/api.proto b/api/grpc/types/api.proto index fe09aee..287fef9 100644 --- a/api/grpc/types/api.proto +++ b/api/grpc/types/api.proto @@ -30,14 +30,13 @@ message UpdateProcessResponse { message CreateContainerRequest { string id = 1; // ID of container string bundlePath = 2; // path to OCI bundle - string checkpoint = 7; // checkpoint name if you want to create immediate checkpoint (optional) + string checkpoint = 3; // checkpoint name if you want to create immediate checkpoint (optional) + string stdin = 4; // path to the file where stdin will be read (optional) + string stdout = 5; // path to file where stdout will be written (optional) + string stderr = 6; // path to file where stderr will be written (optional) } message CreateContainerResponse { - uint32 pid = 1; // PID of the containers main process - string stdin = 2; // path to the file where stdin will be read (optional) - string stdout = 3; // path to file where stdout will be written (optional) - string stderr = 4; // path to file where stderr will be written (optional) } message SignalRequest { @@ -57,7 +56,10 @@ message AddProcessRequest { repeated string env = 5; // List of environment variables for process string cwd = 6; // Workind directory of process string pid = 7; // Process ID -}; + string stdin = 8; // path to the file where stdin will be read (optional) + string stdout = 9; // path to file where stdout will be written (optional) + string stderr = 10; // path to file where stderr will be written (optional) +} message User { uint32 uid = 1; // UID of user @@ -66,9 +68,6 @@ message User { } message AddProcessResponse { - string stdin = 1; // path to the file where stdin will be read (optional) - string stdout = 2; // path to file where stdout will be written (optional) - string stderr = 3; // path to file where stderr will be written (optional) } message CreateCheckpointRequest { diff --git a/containerd-shim/main.go b/containerd-shim/main.go index d7fd0f8..9e46944 100644 --- a/containerd-shim/main.go +++ b/containerd-shim/main.go @@ -41,7 +41,6 @@ func main() { // or if runc exits before we hit the handler signals := make(chan os.Signal, 2048) signal.Notify(signals) - setupLogger() // set the shim as the subreaper for all orphaned processes created by the container if err := util.SetSubreaper(1); err != nil { logrus.WithField("error", err).Fatal("shim: set as subreaper") diff --git a/containerd-shim/process.go b/containerd-shim/process.go index f7fab54..7037170 100644 --- a/containerd-shim/process.go +++ b/containerd-shim/process.go @@ -12,20 +12,19 @@ import ( "github.com/docker/containerd/runtime" "github.com/opencontainers/runc/libcontainer" - "github.com/opencontainers/specs" ) type process struct { id string bundle string stdio *stdio - s specs.Process exec bool containerPid int checkpoint *runtime.Checkpoint shimIO *IO console libcontainer.Console consolePath string + state *runtime.ProcessState } func newProcess(id, bundle string, exec bool, checkpoint string) (*process, error) { @@ -38,7 +37,7 @@ func newProcess(id, bundle string, exec bool, checkpoint string) (*process, erro if err != nil { return nil, err } - p.s = *s + p.state = s if checkpoint != "" { cpt, err := loadCheckpoint(bundle, checkpoint) if err != nil { @@ -52,13 +51,13 @@ func newProcess(id, bundle string, exec bool, checkpoint string) (*process, erro return p, nil } -func loadProcess() (*specs.Process, error) { +func loadProcess() (*runtime.ProcessState, error) { f, err := os.Open("process.json") if err != nil { return nil, err } defer f.Close() - var s specs.Process + var s runtime.ProcessState if err := json.NewDecoder(f).Decode(&s); err != nil { return nil, err } @@ -158,20 +157,24 @@ func (p *process) delete() error { // in RDWR so that they remain open if the other side stops listening func (p *process) openIO() error { p.stdio = &stdio{} - if p.s.Terminal { + var ( + uid = int(p.state.User.UID) + gid = int(p.state.User.GID) + ) + if p.state.Terminal { // FIXME: this is wrong for user namespaces and will need to be translated - console, err := libcontainer.NewConsole(int(p.s.User.UID), int(p.s.User.GID)) + console, err := libcontainer.NewConsole(uid, gid) if err != nil { return err } p.console = console p.consolePath = console.Path() - stdin, err := os.OpenFile("stdin", syscall.O_RDWR, 0) + stdin, err := os.OpenFile(p.state.Stdin, syscall.O_RDWR, 0) if err != nil { return err } go io.Copy(console, stdin) - stdout, err := os.OpenFile("stdout", syscall.O_RDWR, 0) + stdout, err := os.OpenFile(p.state.Stdout, syscall.O_RDWR, 0) if err != nil { return err } @@ -181,20 +184,20 @@ func (p *process) openIO() error { }() return nil } - i, err := p.initializeIO(int(p.s.User.UID)) + i, err := p.initializeIO(uid) if err != nil { return err } p.shimIO = i // non-tty for name, dest := range map[string]func(f *os.File){ - "stdin": func(f *os.File) { + p.state.Stdin: func(f *os.File) { go io.Copy(i.Stdin, f) }, - "stdout": func(f *os.File) { + p.state.Stdout: func(f *os.File) { go io.Copy(f, i.Stdout) }, - "stderr": func(f *os.File) { + p.state.Stderr: func(f *os.File) { go io.Copy(f, i.Stderr) }, } { diff --git a/containerd/main.go b/containerd/main.go index d56da71..62407be 100644 --- a/containerd/main.go +++ b/containerd/main.go @@ -46,7 +46,7 @@ var daemonFlags = []cli.Flag{ }, cli.DurationFlag{ Name: "metrics-interval", - Value: 60 * time.Second, + Value: 120 * time.Second, Usage: "interval for flushing metrics to the store", }, cli.StringFlag{ diff --git a/ctr/container.go b/ctr/container.go index 30232d5..0c558db 100644 --- a/ctr/container.go +++ b/ctr/container.go @@ -50,7 +50,6 @@ var containersCommand = cli.Command{ listCommand, startCommand, statsCommand, - attachCommand, }, Action: listContainers, } @@ -81,77 +80,6 @@ func listContainers(context *cli.Context) { } } -var attachCommand = cli.Command{ - Name: "attach", - Usage: "attach to a running container", - Flags: []cli.Flag{ - cli.StringFlag{ - Name: "state-dir", - Value: "/run/containerd", - Usage: "runtime state directory", - }, - cli.StringFlag{ - Name: "pid,p", - Value: "init", - Usage: "specify the process id to attach to", - }, - }, - Action: func(context *cli.Context) { - var ( - id = context.Args().First() - pid = context.String("pid") - ) - if id == "" { - fatal("container id cannot be empty", 1) - } - c := getClient(context) - type bundleState struct { - Bundle string `json:"bundle"` - } - f, err := os.Open(filepath.Join(context.String("state-dir"), id, "state.json")) - if err != nil { - fatal(err.Error(), 1) - } - var s bundleState - err = json.NewDecoder(f).Decode(&s) - f.Close() - if err != nil { - fatal(err.Error(), 1) - } - mkterm, err := readTermSetting(s.Bundle) - if err != nil { - fatal(err.Error(), 1) - } - if mkterm { - s, err := term.SetRawTerminal(os.Stdin.Fd()) - if err != nil { - fatal(err.Error(), 1) - } - state = s - } - if err := attachStdio( - filepath.Join(context.String("state-dir"), id, pid, "stdin"), - filepath.Join(context.String("state-dir"), id, pid, "stdout"), - filepath.Join(context.String("state-dir"), id, pid, "stderr"), - ); err != nil { - fatal(err.Error(), 1) - } - closer := func() { - if state != nil { - term.RestoreTerminal(os.Stdin.Fd(), state) - } - stdin.Close() - } - go func() { - io.Copy(stdin, os.Stdin) - closer() - }() - if err := waitForExit(c, id, "init", closer); err != nil { - fatal(err.Error(), 1) - } - }, -} - var startCommand = cli.Command{ Name: "start", Usage: "start a container", @@ -181,17 +109,22 @@ var startCommand = cli.Command{ if err != nil { fatal(fmt.Sprintf("cannot get the absolute path of the bundle: %v", err), 1) } - c := getClient(context) - r := &types.CreateContainerRequest{ - Id: id, - BundlePath: bpath, - Checkpoint: context.String("checkpoint"), - } - resp, err := c.CreateContainer(netcontext.Background(), r) + s, err := createStdio() if err != nil { fatal(err.Error(), 1) } - var tty bool + var ( + tty bool + c = getClient(context) + r = &types.CreateContainerRequest{ + Id: id, + BundlePath: bpath, + Checkpoint: context.String("checkpoint"), + Stdin: s.stdin, + Stdout: s.stdout, + Stderr: s.stderr, + } + ) if context.Bool("attach") { mkterm, err := readTermSetting(bpath) if err != nil { @@ -205,10 +138,17 @@ var startCommand = cli.Command{ } state = s } - if err := attachStdio(resp.Stdin, resp.Stdout, resp.Stderr); err != nil { + if err := attachStdio(s); err != nil { fatal(err.Error(), 1) } } + events, err := c.Events(netcontext.Background(), &types.EventsRequest{}) + if err != nil { + fatal(err.Error(), 1) + } + if _, err := c.CreateContainer(netcontext.Background(), r); err != nil { + fatal(err.Error(), 1) + } if context.Bool("attach") { restoreAndCloseStdin := func() { if state != nil { @@ -239,7 +179,7 @@ var startCommand = cli.Command{ } }() } - if err := waitForExit(c, id, "init", restoreAndCloseStdin); err != nil { + if err := waitForExit(c, events, id, "init", restoreAndCloseStdin); err != nil { fatal(err.Error(), 1) } } @@ -282,20 +222,19 @@ func readTermSetting(path string) (bool, error) { return spec.Process.Terminal, nil } -func attachStdio(stdins, stdout, stderr string) error { - stdinf, err := os.OpenFile(stdins, syscall.O_WRONLY, 0) +func attachStdio(s stdio) error { + stdinf, err := os.OpenFile(s.stdin, syscall.O_RDWR, 0) if err != nil { return err } + // FIXME: assign to global stdin = stdinf - - stdoutf, err := os.OpenFile(stdout, syscall.O_RDWR, 0) + stdoutf, err := os.OpenFile(s.stdout, syscall.O_RDWR, 0) if err != nil { return err } go io.Copy(os.Stdout, stdoutf) - - stderrf, err := os.OpenFile(stderr, syscall.O_RDWR, 0) + stderrf, err := os.OpenFile(s.stderr, syscall.O_RDWR, 0) if err != nil { return err } @@ -374,22 +313,24 @@ var execCommand = cli.Command{ }, Action: func(context *cli.Context) { p := &types.AddProcessRequest{ + Id: context.String("id"), Pid: context.String("pid"), Args: context.Args(), Cwd: context.String("cwd"), Terminal: context.Bool("tty"), - Id: context.String("id"), Env: context.StringSlice("env"), User: &types.User{ Uid: uint32(context.Int("uid")), Gid: uint32(context.Int("gid")), }, } - c := getClient(context) - resp, err := c.AddProcess(netcontext.Background(), p) + s, err := createStdio() if err != nil { fatal(err.Error(), 1) } + p.Stdin = s.stdin + p.Stdout = s.stdout + p.Stderr = s.stderr if context.Bool("attach") { if context.Bool("tty") { s, err := term.SetRawTerminal(os.Stdin.Fd()) @@ -398,10 +339,18 @@ var execCommand = cli.Command{ } state = s } - if err := attachStdio(resp.Stdin, resp.Stdout, resp.Stderr); err != nil { + if err := attachStdio(s); err != nil { fatal(err.Error(), 1) } } + c := getClient(context) + events, err := c.Events(netcontext.Background(), &types.EventsRequest{}) + if err != nil { + fatal(err.Error(), 1) + } + if _, err := c.AddProcess(netcontext.Background(), p); err != nil { + fatal(err.Error(), 1) + } if context.Bool("attach") { restoreAndCloseStdin := func() { if state != nil { @@ -411,9 +360,28 @@ var execCommand = cli.Command{ } go func() { io.Copy(stdin, os.Stdin) + if _, err := c.UpdateProcess(netcontext.Background(), &types.UpdateProcessRequest{ + Id: p.Id, + Pid: p.Pid, + CloseStdin: true, + }); err != nil { + log.Println(err) + } restoreAndCloseStdin() }() - if err := waitForExit(c, context.String("id"), context.String("pid"), restoreAndCloseStdin); err != nil { + if context.Bool("tty") { + resize(p.Id, p.Pid, c) + go func() { + s := make(chan os.Signal, 64) + signal.Notify(s, syscall.SIGWINCH) + for range s { + if err := resize(p.Id, p.Pid, c); err != nil { + log.Println(err) + } + } + }() + } + if err := waitForExit(c, events, context.String("id"), context.String("pid"), restoreAndCloseStdin); err != nil { fatal(err.Error(), 1) } } @@ -442,11 +410,7 @@ var statsCommand = cli.Command{ }, } -func waitForExit(c types.APIClient, id, pid string, closer func()) error { - events, err := c.Events(netcontext.Background(), &types.EventsRequest{}) - if err != nil { - return err - } +func waitForExit(c types.APIClient, events types.API_EventsClient, id, pid string, closer func()) error { for { e, err := events.Recv() if err != nil { @@ -461,3 +425,29 @@ func waitForExit(c types.APIClient, id, pid string, closer func()) error { } return nil } + +type stdio struct { + stdin string + stdout string + stderr string +} + +func createStdio() (s stdio, err error) { + tmp, err := ioutil.TempDir("", "ctr-") + if err != nil { + return s, err + } + // create fifo's for the process + for name, fd := range map[string]*string{ + "stdin": &s.stdin, + "stdout": &s.stdout, + "stderr": &s.stderr, + } { + path := filepath.Join(tmp, name) + if err := syscall.Mkfifo(path, 0755); err != nil && !os.IsExist(err) { + return s, err + } + *fd = path + } + return s, nil +} diff --git a/runtime/container.go b/runtime/container.go index 8714c6c..7f5f08c 100644 --- a/runtime/container.go +++ b/runtime/container.go @@ -19,9 +19,9 @@ type Container interface { // Path returns the path to the bundle Path() string // Start starts the init process of the container - Start(checkpoint string) (Process, error) + Start(checkpoint string, s Stdio) (Process, error) // Exec starts another process in an existing container - Exec(string, specs.Process) (Process, error) + Exec(string, specs.Process, Stdio) (Process, error) // Delete removes the container's state and any resources Delete() error // Processes returns all the containers processes that have been added @@ -45,6 +45,12 @@ type Container interface { // OOM() (<-chan struct{}, error) } +type Stdio struct { + Stdin string + Stdout string + Stderr string +} + // New returns a new container func New(root, id, bundle string) (Container, error) { c := &container{ @@ -94,11 +100,11 @@ func Load(root, id string) (Container, error) { continue } pid := d.Name() - s, err := readProcessSpec(filepath.Join(root, id, pid)) + s, err := readProcessState(filepath.Join(root, id, pid)) if err != nil { return nil, err } - p, err := loadProcess(filepath.Join(root, id, pid), pid, c, *s) + p, err := loadProcess(filepath.Join(root, id, pid), pid, c, s) if err != nil { logrus.WithField("id", id).WithField("pid", pid).Debug("containerd: error loading process %s", err) continue @@ -108,13 +114,13 @@ func Load(root, id string) (Container, error) { return c, nil } -func readProcessSpec(dir string) (*specs.Process, error) { +func readProcessState(dir string) (*ProcessState, error) { f, err := os.Open(filepath.Join(dir, "process.json")) if err != nil { return nil, err } defer f.Close() - var s specs.Process + var s ProcessState if err := json.NewDecoder(f).Decode(&s); err != nil { return nil, err } @@ -127,6 +133,7 @@ type container struct { id string bundle string processes map[string]*process + stdio Stdio } func (c *container) ID() string { @@ -137,12 +144,15 @@ func (c *container) Path() string { return c.bundle } -func (c *container) Start(checkpoint string) (Process, error) { +func (c *container) Start(checkpoint string, s Stdio) (Process, error) { processRoot := filepath.Join(c.root, c.id, InitProcessID) - if err := os.MkdirAll(processRoot, 0755); err != nil { + if err := os.Mkdir(processRoot, 0755); err != nil { return nil, err } - cmd := exec.Command("containerd-shim", "-checkpoint", checkpoint, c.id, c.bundle) + cmd := exec.Command("containerd-shim", + "-checkpoint", checkpoint, + c.id, c.bundle, + ) cmd.Dir = processRoot cmd.SysProcAttr = &syscall.SysProcAttr{ Setpgid: true, @@ -151,7 +161,7 @@ func (c *container) Start(checkpoint string) (Process, error) { if err != nil { return nil, err } - p, err := newProcess(processRoot, InitProcessID, c, spec.Process) + p, err := newProcess(processRoot, InitProcessID, c, spec.Process, s) if err != nil { return nil, err } @@ -165,17 +175,20 @@ func (c *container) Start(checkpoint string) (Process, error) { return p, nil } -func (c *container) Exec(pid string, spec specs.Process) (Process, error) { +func (c *container) Exec(pid string, spec specs.Process, s Stdio) (Process, error) { processRoot := filepath.Join(c.root, c.id, pid) - if err := os.MkdirAll(processRoot, 0755); err != nil { + if err := os.Mkdir(processRoot, 0755); err != nil { return nil, err } - cmd := exec.Command("containerd-shim", "-exec", c.id, c.bundle) + cmd := exec.Command("containerd-shim", + "-exec", + c.id, c.bundle, + ) cmd.Dir = processRoot cmd.SysProcAttr = &syscall.SysProcAttr{ Setpgid: true, } - p, err := newProcess(processRoot, pid, c, spec) + p, err := newProcess(processRoot, pid, c, spec, s) if err != nil { return nil, err } @@ -228,7 +241,7 @@ func (c *container) Processes() ([]Process, error) { func (c *container) RemoveProcess(pid string) error { delete(c.processes, pid) - return nil + return os.RemoveAll(filepath.Join(c.root, c.id, pid)) } func (c *container) Checkpoints() ([]Checkpoint, error) { diff --git a/runtime/process.go b/runtime/process.go index b782071..dd430be 100644 --- a/runtime/process.go +++ b/runtime/process.go @@ -21,19 +21,14 @@ type Process interface { // This is either "init" when it is the container's init process or // it is a user provided id for the process similar to the container id ID() string - // Stdin returns the path the the processes stdin fifo - Stdin() string CloseStdin() error Resize(int, int) error - // Stdout returns the path the the processes stdout fifo - Stdout() string - // Stderr returns the path the the processes stderr fifo - Stderr() string // ExitFD returns the fd the provides an event when the process exits ExitFD() int // ExitStatus returns the exit status of the process or an error if it // has not exited ExitStatus() (int, error) + // Spec returns the process spec that created the process Spec() specs.Process // Signal sends the provided signal to the process Signal(os.Signal) error @@ -41,33 +36,27 @@ type Process interface { Container() Container } -func newProcess(root, id string, c *container, s specs.Process) (*process, error) { +func newProcess(root, id string, c *container, s specs.Process, stdio Stdio) (*process, error) { p := &process{ root: root, id: id, container: c, spec: s, + stdio: stdio, } f, err := os.Create(filepath.Join(root, "process.json")) if err != nil { return nil, err } defer f.Close() - if err := json.NewEncoder(f).Encode(s); err != nil { + if err := json.NewEncoder(f).Encode(ProcessState{ + Process: s, + Stdin: stdio.Stdin, + Stdout: stdio.Stdout, + Stderr: stdio.Stderr, + }); err != nil { return nil, err } - // create fifo's for the process - for name, fd := range map[string]*string{ - "stdin": &p.stdin, - "stdout": &p.stdout, - "stderr": &p.stderr, - } { - path := filepath.Join(root, name) - if err := syscall.Mkfifo(path, 0755); err != nil && !os.IsExist(err) { - return nil, err - } - *fd = path - } exit, err := getExitPipe(filepath.Join(root, ExitFile)) if err != nil { return nil, err @@ -81,15 +70,17 @@ func newProcess(root, id string, c *container, s specs.Process) (*process, error return p, nil } -func loadProcess(root, id string, c *container, s specs.Process) (*process, error) { +func loadProcess(root, id string, c *container, s *ProcessState) (*process, error) { p := &process{ root: root, id: id, container: c, - spec: s, - stdin: filepath.Join(root, "stdin"), - stdout: filepath.Join(root, "stdout"), - stderr: filepath.Join(root, "stderr"), + spec: s.Process, + stdio: Stdio{ + Stdin: s.Stdin, + Stdout: s.Stdout, + Stderr: s.Stderr, + }, } if _, err := p.ExitStatus(); err != nil { if err == ErrProcessNotExited { @@ -122,18 +113,14 @@ func getControlPipe(path string) (*os.File, error) { } type process struct { - root string - id string - pid int - // stdio fifos - stdin string - stdout string - stderr string - + root string + id string + pid int exitPipe *os.File controlPipe *os.File container *container spec specs.Process + stdio Stdio } func (p *process) ID() string { @@ -182,18 +169,6 @@ func (p *process) Spec() specs.Process { return p.spec } -func (p *process) Stdin() string { - return p.stdin -} - -func (p *process) Stdout() string { - return p.stdout -} - -func (p *process) Stderr() string { - return p.stderr -} - // Close closes any open files and/or resouces on the process func (p *process) Close() error { return p.exitPipe.Close() diff --git a/runtime/runtime.go b/runtime/runtime.go index b921dd8..cb07db9 100644 --- a/runtime/runtime.go +++ b/runtime/runtime.go @@ -3,6 +3,8 @@ package runtime import ( "errors" "time" + + "github.com/opencontainers/specs" ) var ( @@ -35,6 +37,16 @@ const ( type state struct { Bundle string `json:"bundle"` + Stdin string `json:"stdin"` + Stdout string `json:"stdout"` + Stderr string `json:"stderr"` +} + +type ProcessState struct { + specs.Process + Stdin string `json:"containerdStdin"` + Stdout string `json:"containerdStdout"` + Stderr string `json:"containerdStderr"` } type Stat struct { diff --git a/supervisor/add_process.go b/supervisor/add_process.go index 9a3f68e..3f6d34d 100644 --- a/supervisor/add_process.go +++ b/supervisor/add_process.go @@ -1,6 +1,10 @@ package supervisor -import "time" +import ( + "time" + + "github.com/docker/containerd/runtime" +) type AddProcessEvent struct { s *Supervisor @@ -14,7 +18,11 @@ func (h *AddProcessEvent) Handle(e *Event) error { if !ok { return ErrContainerNotFound } - process, err := ci.container.Exec(e.Pid, *e.ProcessSpec) + process, err := ci.container.Exec(e.Pid, *e.ProcessSpec, runtime.Stdio{ + Stdin: e.Stdin, + Stdout: e.Stdout, + Stderr: e.Stderr, + }) if err != nil { return err } @@ -22,10 +30,6 @@ func (h *AddProcessEvent) Handle(e *Event) error { return err } ExecProcessTimer.UpdateSince(start) - e.StartResponse <- StartResponse{ - Stdin: process.Stdin(), - Stdout: process.Stdout(), - Stderr: process.Stderr(), - } + e.StartResponse <- StartResponse{} return nil } diff --git a/supervisor/create.go b/supervisor/create.go index 6e307b7..8b7f96f 100644 --- a/supervisor/create.go +++ b/supervisor/create.go @@ -24,6 +24,9 @@ func (h *StartEvent) Handle(e *Event) error { Err: e.Err, Container: container, StartResponse: e.StartResponse, + Stdin: e.Stdin, + Stdout: e.Stdout, + Stderr: e.Stderr, } if e.Checkpoint != nil { task.Checkpoint = e.Checkpoint.Name diff --git a/supervisor/event.go b/supervisor/event.go index 3f4b5af..2704dc5 100644 --- a/supervisor/event.go +++ b/supervisor/event.go @@ -37,9 +37,6 @@ func NewEvent(t EventType) *Event { } type StartResponse struct { - Stdin string - Stdout string - Stderr string } type Event struct { diff --git a/supervisor/worker.go b/supervisor/worker.go index 597dbac..30ab65d 100644 --- a/supervisor/worker.go +++ b/supervisor/worker.go @@ -38,7 +38,11 @@ func (w *worker) Start() { defer w.wg.Done() for t := range w.s.tasks { started := time.Now() - process, err := t.Container.Start(t.Checkpoint) + process, err := t.Container.Start(t.Checkpoint, runtime.Stdio{ + Stdin: t.Stdin, + Stdout: t.Stdout, + Stderr: t.Stderr, + }) if err != nil { evt := NewEvent(DeleteEventType) evt.ID = t.Container.ID() @@ -61,10 +65,6 @@ func (w *worker) Start() { } ContainerStartTimer.UpdateSince(started) t.Err <- nil - t.StartResponse <- StartResponse{ - Stdin: process.Stdin(), - Stdout: process.Stdout(), - Stderr: process.Stderr(), - } + t.StartResponse <- StartResponse{} } }