Merge pull request #1158 from crosbymichael/task-events

Refactor runtime events into Task* types
This commit is contained in:
Derek McGowan 2017-07-12 11:17:01 -07:00 committed by GitHub
commit c63b84dcbc
17 changed files with 1831 additions and 2249 deletions

View File

@ -11,7 +11,6 @@
github.com/containerd/containerd/api/services/events/v1/events.proto github.com/containerd/containerd/api/services/events/v1/events.proto
github.com/containerd/containerd/api/services/events/v1/image.proto github.com/containerd/containerd/api/services/events/v1/image.proto
github.com/containerd/containerd/api/services/events/v1/namespace.proto github.com/containerd/containerd/api/services/events/v1/namespace.proto
github.com/containerd/containerd/api/services/events/v1/runtime.proto
github.com/containerd/containerd/api/services/events/v1/snapshot.proto github.com/containerd/containerd/api/services/events/v1/snapshot.proto
github.com/containerd/containerd/api/services/events/v1/task.proto github.com/containerd/containerd/api/services/events/v1/task.proto
@ -29,17 +28,19 @@
NamespaceCreate NamespaceCreate
NamespaceUpdate NamespaceUpdate
NamespaceDelete NamespaceDelete
RuntimeIO
RuntimeMount
RuntimeCreate
RuntimeEvent
RuntimeDelete
SnapshotPrepare SnapshotPrepare
SnapshotCommit SnapshotCommit
SnapshotRemove SnapshotRemove
TaskCreate TaskCreate
TaskStart TaskStart
TaskDelete TaskDelete
TaskIO
TaskExit
TaskOOM
TaskExecAdded
TaskPaused
TaskResumed
TaskCheckpointed
*/ */
package events package events

File diff suppressed because it is too large Load Diff

View File

@ -1,56 +0,0 @@
syntax = "proto3";
package containerd.services.events.v1;
import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";
option go_package = "github.com/containerd/containerd/api/services/events/v1;events";
message RuntimeIO {
string stdin = 1;
string stdout = 2;
string stderr = 3;
bool terminal = 4;
}
message RuntimeMount {
string type = 1;
string source = 2;
repeated string options = 3;
}
message RuntimeCreate {
string container_id = 1;
string bundle = 2;
repeated RuntimeMount rootfs = 3 [(gogoproto.customname) = "RootFS"];
RuntimeIO io = 4 [(gogoproto.customname) = "IO"];
string checkpoint = 5;
}
message RuntimeEvent {
string id = 1;
string container_id = 2;
enum EventType {
EXIT = 0;
OOM = 1;
CREATE = 2;
START = 3;
EXEC_ADDED = 4;
PAUSED = 5;
RESUMED = 6;
CHECKPOINTED = 7;
}
EventType type = 3;
uint32 pid = 4;
uint32 exit_status = 5;
google.protobuf.Timestamp exited_at = 6 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false];
google.protobuf.Timestamp timestamp = 7 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false];
}
message RuntimeDelete {
string container_id = 1;
string runtime = 2;
uint32 exit_status = 3;
google.protobuf.Timestamp exited_at = 4 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false];
}

File diff suppressed because it is too large Load Diff

View File

@ -2,18 +2,67 @@ syntax = "proto3";
package containerd.services.events.v1; package containerd.services.events.v1;
import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";
import "github.com/containerd/containerd/api/types/mount.proto";
option go_package = "github.com/containerd/containerd/api/services/events/v1;events"; option go_package = "github.com/containerd/containerd/api/services/events/v1;events";
message TaskCreate { message TaskCreate {
string container_id = 1; string container_id = 1;
string bundle = 2;
repeated containerd.types.Mount rootfs = 3;
TaskIO io = 4 [(gogoproto.customname) = "IO"];
string checkpoint = 5;
uint32 pid = 6;
} }
message TaskStart { message TaskStart {
string container_id = 1; string container_id = 1;
uint32 pid = 2;
} }
message TaskDelete { message TaskDelete {
string container_id = 1; string container_id = 1;
uint32 pid = 2; uint32 pid = 2;
uint32 exit_status = 3; uint32 exit_status = 3;
google.protobuf.Timestamp exited_at = 4 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false];
}
message TaskIO {
string stdin = 1;
string stdout = 2;
string stderr = 3;
bool terminal = 4;
}
message TaskExit {
string container_id = 1;
string id = 2;
uint32 pid = 3;
uint32 exit_status = 4;
google.protobuf.Timestamp exited_at = 5 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false];
}
message TaskOOM {
string container_id = 1;
}
message TaskExecAdded {
string container_id = 1;
string exec_id = 2;
uint32 pid = 3;
}
message TaskPaused {
string container_id = 1;
}
message TaskResumed {
string container_id = 1;
}
message TaskCheckpointed {
string container_id = 1;
string checkpoint = 2;
} }

View File

@ -1,9 +1,9 @@
package main package main
import ( import (
"encoding/json"
"fmt" "fmt"
"os" "os"
"strings"
"text/tabwriter" "text/tabwriter"
eventsapi "github.com/containerd/containerd/api/services/events/v1" eventsapi "github.com/containerd/containerd/api/services/events/v1"
@ -33,7 +33,11 @@ var eventsCommand = cli.Command{
return err return err
} }
out, err := getEventOutput(e) v, err := typeurl.UnmarshalAny(e.Event)
if err != nil {
return err
}
out, err := json.Marshal(v)
if err != nil { if err != nil {
return err return err
} }
@ -54,54 +58,3 @@ var eventsCommand = cli.Command{
} }
}, },
} }
func getEventOutput(env *eventsapi.Envelope) (string, error) {
out := ""
v, err := typeurl.UnmarshalAny(env.Event)
if err != nil {
return "", err
}
switch e := v.(type) {
case *eventsapi.ContainerCreate:
out = fmt.Sprintf("id=%s image=%s runtime=%s", e.ID, e.Image, e.Runtime)
case *eventsapi.TaskCreate:
out = "id=" + e.ContainerID
case *eventsapi.TaskStart:
out = "id=" + e.ContainerID
case *eventsapi.TaskDelete:
out = fmt.Sprintf("id=%s pid=%d status=%d", e.ContainerID, e.Pid, e.ExitStatus)
case *eventsapi.ContainerUpdate:
out = "id=" + e.ID
case *eventsapi.ContainerDelete:
out = "id=" + e.ID
case *eventsapi.SnapshotPrepare:
out = fmt.Sprintf("key=%s parent=%s", e.Key, e.Parent)
case *eventsapi.SnapshotCommit:
out = fmt.Sprintf("key=%s name=%s", e.Key, e.Name)
case *eventsapi.SnapshotRemove:
out = "key=" + e.Key
case *eventsapi.ImageUpdate:
out = fmt.Sprintf("name=%s labels=%s", e.Name, e.Labels)
case *eventsapi.ImageDelete:
out = "name=" + e.Name
case *eventsapi.NamespaceCreate:
out = fmt.Sprintf("name=%s labels=%s", e.Name, e.Labels)
case *eventsapi.NamespaceUpdate:
out = fmt.Sprintf("name=%s labels=%s", e.Name, e.Labels)
case *eventsapi.NamespaceDelete:
out = "name=" + e.Name
case *eventsapi.RuntimeCreate:
mounts := []string{}
for _, m := range e.RootFS {
mounts = append(mounts, fmt.Sprintf("type=%s:src=%s", m.Type, m.Source))
}
out = fmt.Sprintf("id=%s bundle=%s rootfs=%s checkpoint=%s", e.ContainerID, e.Bundle, strings.Join(mounts, ","), e.Checkpoint)
case *eventsapi.RuntimeEvent:
out = fmt.Sprintf("id=%s container_id=%s type=%s pid=%d status=%d exited=%s", e.ID, e.ContainerID, e.Type, e.Pid, e.ExitStatus, e.ExitedAt)
case *eventsapi.RuntimeDelete:
out = fmt.Sprintf("id=%s runtime=%s status=%d exited=%s", e.ContainerID, e.Runtime, e.ExitStatus, e.ExitedAt)
default:
out = env.Event.TypeUrl
}
return out, nil
}

View File

@ -62,7 +62,6 @@ var shimCommand = cli.Command{
shimCreateCommand, shimCreateCommand,
shimStartCommand, shimStartCommand,
shimDeleteCommand, shimDeleteCommand,
shimEventsCommand,
shimStateCommand, shimStateCommand,
shimExecCommand, shimExecCommand,
}, },
@ -293,28 +292,6 @@ var shimExecCommand = cli.Command{
}, },
} }
var shimEventsCommand = cli.Command{
Name: "events",
Usage: "get events for a shim",
Action: func(context *cli.Context) error {
service, err := getShimService(context)
if err != nil {
return err
}
events, err := service.Stream(gocontext.Background(), &shim.StreamEventsRequest{})
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)
}
},
}
func getShimService(context *cli.Context) (shim.ShimClient, error) { func getShimService(context *cli.Context) (shim.ShimClient, error) {
bindSocket := context.GlobalString("socket") bindSocket := context.GlobalString("socket")
if bindSocket == "" { if bindSocket == "" {

View File

@ -12,9 +12,7 @@ import (
"google.golang.org/grpc" "google.golang.org/grpc"
"github.com/boltdb/bolt" "github.com/boltdb/bolt"
eventsapi "github.com/containerd/containerd/api/services/events/v1"
"github.com/containerd/containerd/api/types" "github.com/containerd/containerd/api/types"
"github.com/containerd/containerd/events"
client "github.com/containerd/containerd/linux/shim" client "github.com/containerd/containerd/linux/shim"
shim "github.com/containerd/containerd/linux/shim/v1" shim "github.com/containerd/containerd/linux/shim/v1"
"github.com/containerd/containerd/log" "github.com/containerd/containerd/log"
@ -92,7 +90,6 @@ func New(ic *plugin.InitContext) (interface{}, error) {
runtime: cfg.Runtime, runtime: cfg.Runtime,
monitor: monitor.(runtime.TaskMonitor), monitor: monitor.(runtime.TaskMonitor),
tasks: newTaskList(), tasks: newTaskList(),
emitter: events.GetPoster(ic.Context),
db: m.(*bolt.DB), db: m.(*bolt.DB),
address: ic.Address, address: ic.Address,
} }
@ -118,7 +115,6 @@ type Runtime struct {
monitor runtime.TaskMonitor monitor runtime.TaskMonitor
tasks *taskList tasks *taskList
emitter events.Poster
db *bolt.DB db *bolt.DB
} }
@ -180,29 +176,6 @@ func (r *Runtime) Create(ctx context.Context, id string, opts runtime.CreateOpts
if err = r.monitor.Monitor(t); err != nil { if err = r.monitor.Monitor(t); err != nil {
return nil, err return nil, err
} }
var runtimeMounts []*eventsapi.RuntimeMount
for _, m := range opts.Rootfs {
runtimeMounts = append(runtimeMounts, &eventsapi.RuntimeMount{
Type: m.Type,
Source: m.Source,
Options: m.Options,
})
}
if err := r.emit(ctx, "/runtime/create", &eventsapi.RuntimeCreate{
ContainerID: id,
Bundle: bundle.path,
RootFS: runtimeMounts,
IO: &eventsapi.RuntimeIO{
Stdin: opts.IO.Stdin,
Stdout: opts.IO.Stdout,
Stderr: opts.IO.Stderr,
Terminal: opts.IO.Terminal,
},
Checkpoint: opts.Checkpoint,
}); err != nil {
return nil, err
}
return t, nil return t, nil
} }
@ -227,23 +200,15 @@ func (r *Runtime) Delete(ctx context.Context, c runtime.Task) (*runtime.Exit, er
} }
r.tasks.delete(ctx, lc) r.tasks.delete(ctx, lc)
var ( bundle := loadBundle(filepath.Join(r.root, namespace, lc.id), namespace)
bundle = loadBundle(filepath.Join(r.root, namespace, lc.id), namespace) if err := bundle.Delete(); err != nil {
i = c.Info()
)
if err := r.emit(ctx, "/runtime/delete", &eventsapi.RuntimeDelete{
ContainerID: i.ID,
Runtime: i.Runtime,
ExitStatus: rsp.ExitStatus,
ExitedAt: rsp.ExitedAt,
}); err != nil {
return nil, err return nil, err
} }
return &runtime.Exit{ return &runtime.Exit{
Status: rsp.ExitStatus, Status: rsp.ExitStatus,
Timestamp: rsp.ExitedAt, Timestamp: rsp.ExitedAt,
Pid: rsp.Pid, Pid: rsp.Pid,
}, bundle.Delete() }, nil
} }
func (r *Runtime) Tasks(ctx context.Context) ([]runtime.Task, error) { func (r *Runtime) Tasks(ctx context.Context) ([]runtime.Task, error) {
@ -356,12 +321,3 @@ func (r *Runtime) getRuntime(ctx context.Context, ns, id string) (*runc.Runc, er
Root: filepath.Join(client.RuncRoot, ns), Root: filepath.Join(client.RuncRoot, ns),
}, nil }, nil
} }
func (r *Runtime) emit(ctx context.Context, topic string, evt interface{}) error {
emitterCtx := events.WithTopic(ctx, topic)
if err := r.emitter.Post(emitterCtx, evt); err != nil {
return err
}
return nil
}

View File

@ -12,7 +12,6 @@ import (
"golang.org/x/net/context" "golang.org/x/net/context"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/metadata"
) )
// NewLocal returns a shim client implementation for issue commands to a shim // NewLocal returns a shim client implementation for issue commands to a shim
@ -54,13 +53,6 @@ func (c *local) ResizePty(ctx context.Context, in *shimapi.ResizePtyRequest, opt
return c.s.ResizePty(ctx, in) return c.s.ResizePty(ctx, in)
} }
func (c *local) Stream(ctx context.Context, in *shimapi.StreamEventsRequest, opts ...grpc.CallOption) (shimapi.Shim_StreamClient, error) {
return &streamEvents{
c: c.s.events,
ctx: ctx,
}, nil
}
func (c *local) State(ctx context.Context, in *shimapi.StateRequest, opts ...grpc.CallOption) (*shimapi.StateResponse, error) { func (c *local) State(ctx context.Context, in *shimapi.StateRequest, opts ...grpc.CallOption) (*shimapi.StateResponse, error) {
return c.s.State(ctx, in) return c.s.State(ctx, in)
} }
@ -97,40 +89,6 @@ func (c *local) Update(ctx context.Context, in *shimapi.UpdateTaskRequest, opts
return c.s.Update(ctx, in) return c.s.Update(ctx, in)
} }
type streamEvents struct {
c chan *events.RuntimeEvent
ctx context.Context
}
func (e *streamEvents) Recv() (*events.RuntimeEvent, error) {
ev := <-e.c
return ev, nil
}
func (e *streamEvents) Header() (metadata.MD, error) {
return nil, nil
}
func (e *streamEvents) Trailer() metadata.MD {
return nil
}
func (e *streamEvents) CloseSend() error {
return nil
}
func (e *streamEvents) Context() context.Context {
return e.ctx
}
func (e *streamEvents) SendMsg(m interface{}) error {
return nil
}
func (e *streamEvents) RecvMsg(m interface{}) error {
return nil
}
type poster interface { type poster interface {
Post(ctx context.Context, in *events.PostEventRequest, opts ...grpc.CallOption) (*google_protobuf.Empty, error) Post(ctx context.Context, in *events.PostEventRequest, opts ...grpc.CallOption) (*google_protobuf.Empty, error)
} }

View File

@ -54,7 +54,7 @@ func NewService(path, namespace, address string) (*Service, error) {
s := &Service{ s := &Service{
path: path, path: path,
processes: make(map[string]process), processes: make(map[string]process),
events: make(chan *events.RuntimeEvent, 4096), events: make(chan interface{}, 4096),
namespace: namespace, namespace: namespace,
context: context, context: context,
} }
@ -69,9 +69,9 @@ type Service struct {
bundle string bundle string
mu sync.Mutex mu sync.Mutex
processes map[string]process processes map[string]process
events chan *events.RuntimeEvent events chan interface{}
eventsMu sync.Mutex eventsMu sync.Mutex
deferredEvent *events.RuntimeEvent deferredEvent interface{}
namespace string namespace string
context context.Context context context.Context
} }
@ -96,11 +96,18 @@ func (s *Service) Create(ctx context.Context, r *shimapi.CreateTaskRequest) (*sh
ExitCh: make(chan int, 1), ExitCh: make(chan int, 1),
} }
reaper.Default.Register(pid, cmd) reaper.Default.Register(pid, cmd)
s.events <- &events.RuntimeEvent{ s.events <- &events.TaskCreate{
Type: events.RuntimeEvent_CREATE, ContainerID: r.ID,
ID: r.ID, Bundle: r.Bundle,
ContainerID: s.id, Rootfs: r.Rootfs,
Pid: uint32(pid), IO: &events.TaskIO{
Stdin: r.Stdin,
Stdout: r.Stdout,
Stderr: r.Stderr,
Terminal: r.Terminal,
},
Checkpoint: r.Checkpoint,
Pid: uint32(pid),
} }
go s.waitExit(process, pid, cmd) go s.waitExit(process, pid, cmd)
return &shimapi.CreateTaskResponse{ return &shimapi.CreateTaskResponse{
@ -115,9 +122,7 @@ func (s *Service) Start(ctx context.Context, r *google_protobuf.Empty) (*google_
if err := s.initProcess.Start(ctx); err != nil { if err := s.initProcess.Start(ctx); err != nil {
return nil, err return nil, err
} }
s.events <- &events.RuntimeEvent{ s.events <- &events.TaskStart{
Type: events.RuntimeEvent_START,
ID: s.id,
ContainerID: s.id, ContainerID: s.id,
Pid: uint32(s.initProcess.Pid()), Pid: uint32(s.initProcess.Pid()),
} }
@ -134,6 +139,12 @@ func (s *Service) Delete(ctx context.Context, r *google_protobuf.Empty) (*shimap
s.mu.Lock() s.mu.Lock()
delete(s.processes, p.ID()) delete(s.processes, p.ID())
s.mu.Unlock() s.mu.Unlock()
s.events <- &events.TaskDelete{
ContainerID: s.id,
ExitStatus: uint32(p.Status()),
ExitedAt: p.ExitedAt(),
Pid: uint32(p.Pid()),
}
return &shimapi.DeleteResponse{ return &shimapi.DeleteResponse{
ExitStatus: uint32(p.Status()), ExitStatus: uint32(p.Status()),
ExitedAt: p.ExitedAt(), ExitedAt: p.ExitedAt(),
@ -184,10 +195,9 @@ func (s *Service) Exec(ctx context.Context, r *shimapi.ExecProcessRequest) (*shi
reaper.Default.Register(pid, cmd) reaper.Default.Register(pid, cmd)
s.processes[r.ID] = process s.processes[r.ID] = process
s.events <- &events.RuntimeEvent{ s.events <- &events.TaskExecAdded{
Type: events.RuntimeEvent_EXEC_ADDED,
ID: r.ID,
ContainerID: s.id, ContainerID: s.id,
ExecID: r.ID,
Pid: uint32(pid), Pid: uint32(pid),
} }
go s.waitExit(process, pid, cmd) go s.waitExit(process, pid, cmd)
@ -216,30 +226,6 @@ func (s *Service) ResizePty(ctx context.Context, r *shimapi.ResizePtyRequest) (*
return empty, nil return empty, nil
} }
func (s *Service) Stream(r *shimapi.StreamEventsRequest, stream shimapi.Shim_StreamServer) error {
s.eventsMu.Lock()
defer s.eventsMu.Unlock()
if s.deferredEvent != nil {
if err := stream.Send(s.deferredEvent); err != nil {
return err
}
s.deferredEvent = nil
}
for {
select {
case e := <-s.events:
if err := stream.Send(e); err != nil {
s.deferredEvent = e
return err
}
case <-stream.Context().Done():
return stream.Context().Err()
}
}
}
func (s *Service) State(ctx context.Context, r *shimapi.StateRequest) (*shimapi.StateResponse, error) { func (s *Service) State(ctx context.Context, r *shimapi.StateRequest) (*shimapi.StateResponse, error) {
if s.initProcess == nil { if s.initProcess == nil {
return nil, errors.New(ErrContainerNotCreated) return nil, errors.New(ErrContainerNotCreated)
@ -283,11 +269,8 @@ func (s *Service) Pause(ctx context.Context, r *google_protobuf.Empty) (*google_
if err := s.initProcess.Pause(ctx); err != nil { if err := s.initProcess.Pause(ctx); err != nil {
return nil, err return nil, err
} }
s.events <- &events.RuntimeEvent{ s.events <- &events.TaskPaused{
Type: events.RuntimeEvent_PAUSED,
ID: s.id,
ContainerID: s.id, ContainerID: s.id,
Timestamp: time.Now(),
} }
return empty, nil return empty, nil
} }
@ -299,11 +282,8 @@ func (s *Service) Resume(ctx context.Context, r *google_protobuf.Empty) (*google
if err := s.initProcess.Resume(ctx); err != nil { if err := s.initProcess.Resume(ctx); err != nil {
return nil, err return nil, err
} }
s.events <- &events.RuntimeEvent{ s.events <- &events.TaskResumed{
Type: events.RuntimeEvent_RESUMED,
ID: s.id,
ContainerID: s.id, ContainerID: s.id,
Timestamp: time.Now(),
} }
return empty, nil return empty, nil
} }
@ -356,11 +336,8 @@ func (s *Service) Checkpoint(ctx context.Context, r *shimapi.CheckpointTaskReque
if err := s.initProcess.Checkpoint(ctx, r); err != nil { if err := s.initProcess.Checkpoint(ctx, r); err != nil {
return nil, err return nil, err
} }
s.events <- &events.RuntimeEvent{ s.events <- &events.TaskCheckpointed{
Type: events.RuntimeEvent_CHECKPOINTED,
ID: s.id,
ContainerID: s.id, ContainerID: s.id,
Timestamp: time.Now(),
} }
return empty, nil return empty, nil
} }
@ -386,10 +363,9 @@ func (s *Service) waitExit(p process, pid int, cmd *reaper.Cmd) {
p.Exited(status) p.Exited(status)
reaper.Default.Delete(pid) reaper.Default.Delete(pid)
s.events <- &events.RuntimeEvent{ s.events <- &events.TaskExit{
Type: events.RuntimeEvent_EXIT,
ID: p.ID(),
ContainerID: s.id, ContainerID: s.id,
ID: p.ID(),
Pid: uint32(pid), Pid: uint32(pid),
ExitStatus: uint32(status), ExitStatus: uint32(status),
ExitedAt: p.ExitedAt(), ExitedAt: p.ExitedAt(),
@ -418,7 +394,7 @@ func (s *Service) forward(client poster) {
if _, err := client.Post(s.context, &events.PostEventRequest{ if _, err := client.Post(s.context, &events.PostEventRequest{
Envelope: &events.Envelope{ Envelope: &events.Envelope{
Timestamp: time.Now(), Timestamp: time.Now(),
Topic: "/runtime/" + getTopic(e), Topic: "/task/" + getTopic(e),
Event: a, Event: a,
}, },
}); err != nil { }); err != nil {
@ -427,18 +403,26 @@ func (s *Service) forward(client poster) {
} }
} }
func getTopic(e *events.RuntimeEvent) string { func getTopic(e interface{}) string {
switch e.Type { switch e.(type) {
case events.RuntimeEvent_CREATE: case *events.TaskCreate:
return "task-create" return "task-create"
case events.RuntimeEvent_START: case *events.TaskStart:
return "task-start" return "task-start"
case events.RuntimeEvent_EXEC_ADDED: case *events.TaskOOM:
return "task-execadded"
case events.RuntimeEvent_OOM:
return "task-oom" return "task-oom"
case events.RuntimeEvent_EXIT: case *events.TaskExit:
return "task-exit" return "task-exit"
case *events.TaskDelete:
return "task-delete"
case *events.TaskExecAdded:
return "task-exec-added"
case *events.TaskPaused:
return "task-paused"
case *events.TaskResumed:
return "task-resumed"
case *events.TaskCheckpointed:
return "task-checkpointed"
} }
return "?" return "?"
} }

View File

@ -24,7 +24,6 @@
ListPidsResponse ListPidsResponse
CheckpointTaskRequest CheckpointTaskRequest
ShimInfoResponse ShimInfoResponse
StreamEventsRequest
UpdateTaskRequest UpdateTaskRequest
*/ */
package shim package shim
@ -38,7 +37,6 @@ import _ "github.com/gogo/protobuf/gogoproto"
import _ "github.com/gogo/protobuf/types" import _ "github.com/gogo/protobuf/types"
import containerd_types "github.com/containerd/containerd/api/types" import containerd_types "github.com/containerd/containerd/api/types"
import containerd_v1_types "github.com/containerd/containerd/api/types/task" import containerd_v1_types "github.com/containerd/containerd/api/types/task"
import containerd_services_events_v1 "github.com/containerd/containerd/api/services/events/v1"
import time "time" import time "time"
@ -216,20 +214,13 @@ func (m *ShimInfoResponse) Reset() { *m = ShimInfoResponse{}
func (*ShimInfoResponse) ProtoMessage() {} func (*ShimInfoResponse) ProtoMessage() {}
func (*ShimInfoResponse) Descriptor() ([]byte, []int) { return fileDescriptorShim, []int{14} } func (*ShimInfoResponse) Descriptor() ([]byte, []int) { return fileDescriptorShim, []int{14} }
type StreamEventsRequest struct {
}
func (m *StreamEventsRequest) Reset() { *m = StreamEventsRequest{} }
func (*StreamEventsRequest) ProtoMessage() {}
func (*StreamEventsRequest) Descriptor() ([]byte, []int) { return fileDescriptorShim, []int{15} }
type UpdateTaskRequest struct { type UpdateTaskRequest struct {
Resources *google_protobuf.Any `protobuf:"bytes,1,opt,name=resources" json:"resources,omitempty"` Resources *google_protobuf.Any `protobuf:"bytes,1,opt,name=resources" json:"resources,omitempty"`
} }
func (m *UpdateTaskRequest) Reset() { *m = UpdateTaskRequest{} } func (m *UpdateTaskRequest) Reset() { *m = UpdateTaskRequest{} }
func (*UpdateTaskRequest) ProtoMessage() {} func (*UpdateTaskRequest) ProtoMessage() {}
func (*UpdateTaskRequest) Descriptor() ([]byte, []int) { return fileDescriptorShim, []int{16} } func (*UpdateTaskRequest) Descriptor() ([]byte, []int) { return fileDescriptorShim, []int{15} }
func init() { func init() {
proto.RegisterType((*CreateTaskRequest)(nil), "containerd.runtime.linux.shim.v1.CreateTaskRequest") proto.RegisterType((*CreateTaskRequest)(nil), "containerd.runtime.linux.shim.v1.CreateTaskRequest")
@ -247,7 +238,6 @@ func init() {
proto.RegisterType((*ListPidsResponse)(nil), "containerd.runtime.linux.shim.v1.ListPidsResponse") proto.RegisterType((*ListPidsResponse)(nil), "containerd.runtime.linux.shim.v1.ListPidsResponse")
proto.RegisterType((*CheckpointTaskRequest)(nil), "containerd.runtime.linux.shim.v1.CheckpointTaskRequest") proto.RegisterType((*CheckpointTaskRequest)(nil), "containerd.runtime.linux.shim.v1.CheckpointTaskRequest")
proto.RegisterType((*ShimInfoResponse)(nil), "containerd.runtime.linux.shim.v1.ShimInfoResponse") proto.RegisterType((*ShimInfoResponse)(nil), "containerd.runtime.linux.shim.v1.ShimInfoResponse")
proto.RegisterType((*StreamEventsRequest)(nil), "containerd.runtime.linux.shim.v1.StreamEventsRequest")
proto.RegisterType((*UpdateTaskRequest)(nil), "containerd.runtime.linux.shim.v1.UpdateTaskRequest") proto.RegisterType((*UpdateTaskRequest)(nil), "containerd.runtime.linux.shim.v1.UpdateTaskRequest")
} }
@ -272,7 +262,6 @@ type ShimClient interface {
Pause(ctx context.Context, in *google_protobuf1.Empty, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) Pause(ctx context.Context, in *google_protobuf1.Empty, opts ...grpc.CallOption) (*google_protobuf1.Empty, error)
Resume(ctx context.Context, in *google_protobuf1.Empty, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) Resume(ctx context.Context, in *google_protobuf1.Empty, opts ...grpc.CallOption) (*google_protobuf1.Empty, error)
Checkpoint(ctx context.Context, in *CheckpointTaskRequest, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) Checkpoint(ctx context.Context, in *CheckpointTaskRequest, opts ...grpc.CallOption) (*google_protobuf1.Empty, error)
Stream(ctx context.Context, in *StreamEventsRequest, opts ...grpc.CallOption) (Shim_StreamClient, error)
Kill(ctx context.Context, in *KillRequest, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) Kill(ctx context.Context, in *KillRequest, opts ...grpc.CallOption) (*google_protobuf1.Empty, error)
Exec(ctx context.Context, in *ExecProcessRequest, opts ...grpc.CallOption) (*ExecProcessResponse, error) Exec(ctx context.Context, in *ExecProcessRequest, opts ...grpc.CallOption) (*ExecProcessResponse, error)
ResizePty(ctx context.Context, in *ResizePtyRequest, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) ResizePty(ctx context.Context, in *ResizePtyRequest, opts ...grpc.CallOption) (*google_protobuf1.Empty, error)
@ -371,38 +360,6 @@ func (c *shimClient) Checkpoint(ctx context.Context, in *CheckpointTaskRequest,
return out, nil return out, nil
} }
func (c *shimClient) Stream(ctx context.Context, in *StreamEventsRequest, opts ...grpc.CallOption) (Shim_StreamClient, error) {
stream, err := grpc.NewClientStream(ctx, &_Shim_serviceDesc.Streams[0], c.cc, "/containerd.runtime.linux.shim.v1.Shim/Stream", opts...)
if err != nil {
return nil, err
}
x := &shimStreamClient{stream}
if err := x.ClientStream.SendMsg(in); err != nil {
return nil, err
}
if err := x.ClientStream.CloseSend(); err != nil {
return nil, err
}
return x, nil
}
type Shim_StreamClient interface {
Recv() (*containerd_services_events_v1.RuntimeEvent, error)
grpc.ClientStream
}
type shimStreamClient struct {
grpc.ClientStream
}
func (x *shimStreamClient) Recv() (*containerd_services_events_v1.RuntimeEvent, error) {
m := new(containerd_services_events_v1.RuntimeEvent)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
func (c *shimClient) Kill(ctx context.Context, in *KillRequest, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) { func (c *shimClient) Kill(ctx context.Context, in *KillRequest, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) {
out := new(google_protobuf1.Empty) out := new(google_protobuf1.Empty)
err := grpc.Invoke(ctx, "/containerd.runtime.linux.shim.v1.Shim/Kill", in, out, c.cc, opts...) err := grpc.Invoke(ctx, "/containerd.runtime.linux.shim.v1.Shim/Kill", in, out, c.cc, opts...)
@ -470,7 +427,6 @@ type ShimServer interface {
Pause(context.Context, *google_protobuf1.Empty) (*google_protobuf1.Empty, error) Pause(context.Context, *google_protobuf1.Empty) (*google_protobuf1.Empty, error)
Resume(context.Context, *google_protobuf1.Empty) (*google_protobuf1.Empty, error) Resume(context.Context, *google_protobuf1.Empty) (*google_protobuf1.Empty, error)
Checkpoint(context.Context, *CheckpointTaskRequest) (*google_protobuf1.Empty, error) Checkpoint(context.Context, *CheckpointTaskRequest) (*google_protobuf1.Empty, error)
Stream(*StreamEventsRequest, Shim_StreamServer) error
Kill(context.Context, *KillRequest) (*google_protobuf1.Empty, error) Kill(context.Context, *KillRequest) (*google_protobuf1.Empty, error)
Exec(context.Context, *ExecProcessRequest) (*ExecProcessResponse, error) Exec(context.Context, *ExecProcessRequest) (*ExecProcessResponse, error)
ResizePty(context.Context, *ResizePtyRequest) (*google_protobuf1.Empty, error) ResizePty(context.Context, *ResizePtyRequest) (*google_protobuf1.Empty, error)
@ -646,27 +602,6 @@ func _Shim_Checkpoint_Handler(srv interface{}, ctx context.Context, dec func(int
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
func _Shim_Stream_Handler(srv interface{}, stream grpc.ServerStream) error {
m := new(StreamEventsRequest)
if err := stream.RecvMsg(m); err != nil {
return err
}
return srv.(ShimServer).Stream(m, &shimStreamServer{stream})
}
type Shim_StreamServer interface {
Send(*containerd_services_events_v1.RuntimeEvent) error
grpc.ServerStream
}
type shimStreamServer struct {
grpc.ServerStream
}
func (x *shimStreamServer) Send(m *containerd_services_events_v1.RuntimeEvent) error {
return x.ServerStream.SendMsg(m)
}
func _Shim_Kill_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { func _Shim_Kill_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(KillRequest) in := new(KillRequest)
if err := dec(in); err != nil { if err := dec(in); err != nil {
@ -840,13 +775,7 @@ var _Shim_serviceDesc = grpc.ServiceDesc{
Handler: _Shim_Update_Handler, Handler: _Shim_Update_Handler,
}, },
}, },
Streams: []grpc.StreamDesc{ Streams: []grpc.StreamDesc{},
{
StreamName: "Stream",
Handler: _Shim_Stream_Handler,
ServerStreams: true,
},
},
Metadata: "github.com/containerd/containerd/linux/shim/v1/shim.proto", Metadata: "github.com/containerd/containerd/linux/shim/v1/shim.proto",
} }
@ -1431,24 +1360,6 @@ func (m *ShimInfoResponse) MarshalTo(dAtA []byte) (int, error) {
return i, nil return i, nil
} }
func (m *StreamEventsRequest) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *StreamEventsRequest) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
return i, nil
}
func (m *UpdateTaskRequest) Marshal() (dAtA []byte, err error) { func (m *UpdateTaskRequest) Marshal() (dAtA []byte, err error) {
size := m.Size() size := m.Size()
dAtA = make([]byte, size) dAtA = make([]byte, size)
@ -1762,12 +1673,6 @@ func (m *ShimInfoResponse) Size() (n int) {
return n return n
} }
func (m *StreamEventsRequest) Size() (n int) {
var l int
_ = l
return n
}
func (m *UpdateTaskRequest) Size() (n int) { func (m *UpdateTaskRequest) Size() (n int) {
var l int var l int
_ = l _ = l
@ -1971,15 +1876,6 @@ func (this *ShimInfoResponse) String() string {
}, "") }, "")
return s return s
} }
func (this *StreamEventsRequest) String() string {
if this == nil {
return "nil"
}
s := strings.Join([]string{`&StreamEventsRequest{`,
`}`,
}, "")
return s
}
func (this *UpdateTaskRequest) String() string { func (this *UpdateTaskRequest) String() string {
if this == nil { if this == nil {
return "nil" return "nil"
@ -3956,56 +3852,6 @@ func (m *ShimInfoResponse) Unmarshal(dAtA []byte) error {
} }
return nil return nil
} }
func (m *StreamEventsRequest) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowShim
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: StreamEventsRequest: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: StreamEventsRequest: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
default:
iNdEx = preIndex
skippy, err := skipShim(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthShim
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *UpdateTaskRequest) Unmarshal(dAtA []byte) error { func (m *UpdateTaskRequest) Unmarshal(dAtA []byte) error {
l := len(dAtA) l := len(dAtA)
iNdEx := 0 iNdEx := 0
@ -4199,75 +4045,71 @@ func init() {
} }
var fileDescriptorShim = []byte{ var fileDescriptorShim = []byte{
// 1117 bytes of a gzipped FileDescriptorProto // 1049 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x57, 0x4d, 0x6f, 0xdb, 0x46, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x57, 0x4f, 0x6f, 0xe3, 0x44,
0x13, 0x36, 0xf5, 0x41, 0xc9, 0xa3, 0x57, 0x7e, 0xed, 0x8d, 0xe3, 0x32, 0x0a, 0x20, 0x0b, 0x3c, 0x14, 0x5f, 0xe7, 0xaf, 0xfb, 0x42, 0x4a, 0x3b, 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 0x3a, 0x95, 0x7c, 0x39, 0x82, 0x98, 0xeb, 0xf4, 0xaf, 0x41, 0x97, 0x7d, 0xff, 0xa3, 0x6e, 0xef, 0x88, 0x48, 0x0d, 0x00, 0x00,
0x3b, 0x4f, 0xef, 0x9b, 0xeb, 0xf0, 0x69, 0xee, 0xee, 0x1d, 0xdd, 0xbc, 0x6b, 0x2e, 0xfd, 0xf1,
0xae, 0xb9, 0xf4, 0xd3, 0xa8, 0xa9, 0xdd, 0x8c, 0x9a, 0xda, 0xef, 0xa3, 0xa6, 0xf6, 0xd7, 0xa8,
0xa9, 0x7d, 0xbb, 0xb3, 0xd8, 0x3f, 0x76, 0x9f, 0xf2, 0xdf, 0x33, 0x5d, 0x5c, 0xbf, 0xf3, 0x6f,
0x00, 0x00, 0x00, 0xff, 0xff, 0x8d, 0x23, 0x98, 0xb4, 0x16, 0x0e, 0x00, 0x00,
} }

View File

@ -8,7 +8,6 @@ import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto"; import "google/protobuf/timestamp.proto";
import "github.com/containerd/containerd/api/types/mount.proto"; import "github.com/containerd/containerd/api/types/mount.proto";
import "github.com/containerd/containerd/api/types/task/task.proto"; import "github.com/containerd/containerd/api/types/task/task.proto";
import "github.com/containerd/containerd/api/services/events/v1/runtime.proto";
option go_package = "github.com/containerd/containerd/linux/shim/v1;shim"; option go_package = "github.com/containerd/containerd/linux/shim/v1;shim";
@ -36,8 +35,6 @@ service Shim {
rpc Checkpoint(CheckpointTaskRequest) returns (google.protobuf.Empty); rpc Checkpoint(CheckpointTaskRequest) returns (google.protobuf.Empty);
rpc Stream(StreamEventsRequest) returns (stream containerd.services.events.v1.RuntimeEvent);
rpc Kill(KillRequest) returns (google.protobuf.Empty); rpc Kill(KillRequest) returns (google.protobuf.Empty);
rpc Exec(ExecProcessRequest) returns (ExecProcessResponse); rpc Exec(ExecProcessRequest) returns (ExecProcessResponse);
@ -142,9 +139,6 @@ message ShimInfoResponse {
uint32 shim_pid = 1; uint32 shim_pid = 1;
} }
message StreamEventsRequest {
}
message UpdateTaskRequest { message UpdateTaskRequest {
google.protobuf.Any resources = 1; google.protobuf.Any resources = 1;
} }

View File

@ -3,8 +3,6 @@
package cgroups package cgroups
import ( import (
"time"
"github.com/containerd/cgroups" "github.com/containerd/cgroups"
events "github.com/containerd/containerd/api/services/events/v1" events "github.com/containerd/containerd/api/services/events/v1"
evt "github.com/containerd/containerd/events" evt "github.com/containerd/containerd/events"
@ -71,10 +69,7 @@ func (m *cgroupsMonitor) Stop(c runtime.Task) error {
} }
func (m *cgroupsMonitor) trigger(id string, cg cgroups.Cgroup) { func (m *cgroupsMonitor) trigger(id string, cg cgroups.Cgroup) {
if err := m.emitter.Post(m.context, &events.RuntimeEvent{ if err := m.emitter.Post(m.context, &events.TaskOOM{
Timestamp: time.Now(),
Type: events.RuntimeEvent_OOM,
ID: id,
ContainerID: id, ContainerID: id,
}); err != nil { }); err != nil {
log.G(m.context).WithError(err).Error("post OOM event") log.G(m.context).WithError(err).Error("post OOM event")

View File

@ -65,21 +65,17 @@ func (p *process) Wait(ctx context.Context) (uint32, error) {
if err != nil { if err != nil {
return UnknownExitStatus, err return UnknownExitStatus, err
} }
evloop:
for { for {
evt, err := eventstream.Recv() evt, err := eventstream.Recv()
if err != nil { if err != nil {
return UnknownExitStatus, err return UnknownExitStatus, err
} }
if typeurl.Is(evt.Event, &eventsapi.RuntimeEvent{}) { if typeurl.Is(evt.Event, &eventsapi.TaskExit{}) {
v, err := typeurl.UnmarshalAny(evt.Event) v, err := typeurl.UnmarshalAny(evt.Event)
if err != nil { if err != nil {
return UnknownExitStatus, err return UnknownExitStatus, err
} }
e := v.(*eventsapi.RuntimeEvent) e := v.(*eventsapi.TaskExit)
if e.Type != eventsapi.RuntimeEvent_EXIT {
continue evloop
}
if e.ID == p.id && e.ContainerID == p.task.id { if e.ID == p.id && e.ContainerID == p.task.id {
return e.ExitStatus, nil return e.ExitStatus, nil
} }

View File

@ -153,16 +153,13 @@ func (t *task) Wait(ctx context.Context) (uint32, error) {
if err != nil { if err != nil {
return UnknownExitStatus, err return UnknownExitStatus, err
} }
if typeurl.Is(evt.Event, &eventsapi.RuntimeEvent{}) { if typeurl.Is(evt.Event, &eventsapi.TaskExit{}) {
v, err := typeurl.UnmarshalAny(evt.Event) v, err := typeurl.UnmarshalAny(evt.Event)
if err != nil { if err != nil {
return UnknownExitStatus, err return UnknownExitStatus, err
} }
e := v.(*eventsapi.RuntimeEvent) e := v.(*eventsapi.TaskExit)
if e.Type != eventsapi.RuntimeEvent_EXIT { if e.ContainerID == t.id && e.Pid == t.pid {
continue
}
if e.ID == t.id && e.Pid == t.pid {
return e.ExitStatus, nil return e.ExitStatus, nil
} }
} }

View File

@ -7,9 +7,7 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"sync" "sync"
"time"
events "github.com/containerd/containerd/api/services/events/v1"
"github.com/containerd/containerd/log" "github.com/containerd/containerd/log"
"github.com/containerd/containerd/runtime" "github.com/containerd/containerd/runtime"
"github.com/containerd/containerd/windows/hcs" "github.com/containerd/containerd/windows/hcs"
@ -21,9 +19,7 @@ import (
var ErrLoadedContainer = errors.New("loaded container can only be terminated") var ErrLoadedContainer = errors.New("loaded container can only be terminated")
type eventCallback func(id string, evType events.RuntimeEvent_EventType, pid, exitStatus uint32, exitedAt time.Time) func loadContainers(ctx context.Context, h *hcs.HCS) ([]*container, error) {
func loadContainers(ctx context.Context, h *hcs.HCS, sendEvent eventCallback) ([]*container, error) {
hCtr, err := h.LoadContainers(ctx) hCtr, err := h.LoadContainers(ctx)
if err != nil { if err != nil {
return nil, err return nil, err
@ -32,16 +28,15 @@ func loadContainers(ctx context.Context, h *hcs.HCS, sendEvent eventCallback) ([
containers := make([]*container, 0) containers := make([]*container, 0)
for _, c := range hCtr { for _, c := range hCtr {
containers = append(containers, &container{ containers = append(containers, &container{
ctr: c, ctr: c,
status: runtime.RunningStatus, status: runtime.RunningStatus,
sendEvent: sendEvent,
}) })
} }
return containers, nil return containers, nil
} }
func newContainer(ctx context.Context, h *hcs.HCS, id string, spec *RuntimeSpec, io runtime.IO, sendEvent eventCallback) (*container, error) { func newContainer(ctx context.Context, h *hcs.HCS, id string, spec *RuntimeSpec, io runtime.IO) (*container, error) {
cio, err := hcs.NewIO(io.Stdin, io.Stdout, io.Stderr, io.Terminal) cio, err := hcs.NewIO(io.Stdin, io.Stdout, io.Stderr, io.Terminal)
if err != nil { if err != nil {
return nil, err return nil, err
@ -51,21 +46,19 @@ func newContainer(ctx context.Context, h *hcs.HCS, id string, spec *RuntimeSpec,
if err != nil { if err != nil {
return nil, err return nil, err
} }
sendEvent(id, events.RuntimeEvent_CREATE, hcsCtr.Pid(), 0, time.Time{}) //sendEvent(id, events.RuntimeEvent_CREATE, hcsCtr.Pid(), 0, time.Time{})
return &container{ return &container{
ctr: hcsCtr, ctr: hcsCtr,
status: runtime.CreatedStatus, status: runtime.CreatedStatus,
sendEvent: sendEvent,
}, nil }, nil
} }
type container struct { type container struct {
sync.Mutex sync.Mutex
ctr *hcs.Container ctr *hcs.Container
status runtime.Status status runtime.Status
sendEvent eventCallback
} }
func (c *container) ID() string { func (c *container) ID() string {
@ -90,16 +83,16 @@ func (c *container) Start(ctx context.Context) error {
} }
c.setStatus(runtime.RunningStatus) c.setStatus(runtime.RunningStatus)
c.sendEvent(c.ctr.ID(), events.RuntimeEvent_START, c.ctr.Pid(), 0, time.Time{}) // c.sendEvent(c.ctr.ID(), events.RuntimeEvent_START, c.ctr.Pid(), 0, time.Time{})
// Wait for our process to terminate // Wait for our process to terminate
go func() { go func() {
ec, err := c.ctr.ExitCode() _, err := c.ctr.ExitCode()
if err != nil { if err != nil {
log.G(ctx).Debug(err) log.G(ctx).Debug(err)
} }
c.setStatus(runtime.StoppedStatus) c.setStatus(runtime.StoppedStatus)
c.sendEvent(c.ctr.ID(), events.RuntimeEvent_EXIT, c.ctr.Pid(), ec, c.ctr.Processes()[0].ExitedAt()) // c.sendEvent(c.ctr.ID(), events.RuntimeEvent_EXIT, c.ctr.Pid(), ec, c.ctr.Processes()[0].ExitedAt())
}() }()
return nil return nil
@ -163,11 +156,11 @@ func (c *container) Exec(ctx context.Context, id string, opts runtime.ExecOpts)
} }
go func() { go func() {
ec, err := p.ExitCode() _, err := p.ExitCode()
if err != nil { if err != nil {
log.G(ctx).Debug(err) log.G(ctx).Debug(err)
} }
c.sendEvent(c.ctr.ID(), events.RuntimeEvent_EXEC_ADDED, p.Pid(), ec, p.ExitedAt()) //c.sendEvent(c.ctr.ID(), events.RuntimeEvent_EXEC_ADDED, p.Pid(), ec, p.ExitedAt())
}() }()
return &process{p}, nil return &process{p}, nil

View File

@ -8,9 +8,7 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"sync" "sync"
"time"
events "github.com/containerd/containerd/api/services/events/v1"
"github.com/containerd/containerd/log" "github.com/containerd/containerd/log"
"github.com/containerd/containerd/plugin" "github.com/containerd/containerd/plugin"
"github.com/containerd/containerd/runtime" "github.com/containerd/containerd/runtime"
@ -47,7 +45,7 @@ func New(ic *plugin.InitContext) (interface{}, error) {
r := &Runtime{ r := &Runtime{
pidPool: pid.NewPool(), pidPool: pid.NewPool(),
containers: make(map[string]*container), containers: make(map[string]*container),
events: make(chan *events.RuntimeEvent, 2048), events: make(chan interface{}, 2048),
eventsContext: c, eventsContext: c,
eventsCancel: cancel, eventsCancel: cancel,
rootDir: rootDir, rootDir: rootDir,
@ -56,14 +54,14 @@ func New(ic *plugin.InitContext) (interface{}, error) {
// Terminate all previous container that we may have started. We don't // Terminate all previous container that we may have started. We don't
// support restoring containers // support restoring containers
ctrs, err := loadContainers(ic.Context, r.hcs, r.sendEvent) ctrs, err := loadContainers(ic.Context, r.hcs)
if err != nil { if err != nil {
return nil, err return nil, err
} }
for _, c := range ctrs { for _, c := range ctrs {
c.ctr.Delete(ic.Context) c.ctr.Delete(ic.Context)
r.sendEvent(c.ctr.ID(), events.RuntimeEvent_EXIT, c.ctr.Pid(), 255, time.Time{}) //r.sendEvent(c.ctr.ID(), events.RuntimeEvent_EXIT, c.ctr.Pid(), 255, time.Time{})
} }
// Try to delete the old state dir and recreate it // Try to delete the old state dir and recreate it
@ -90,7 +88,7 @@ type Runtime struct {
containers map[string]*container containers map[string]*container
events chan *events.RuntimeEvent events chan interface{}
eventsContext context.Context eventsContext context.Context
eventsCancel func() eventsCancel func()
} }
@ -113,7 +111,7 @@ func (r *Runtime) Create(ctx context.Context, id string, opts runtime.CreateOpts
return nil, err return nil, err
} }
rtSpec := v.(*RuntimeSpec) rtSpec := v.(*RuntimeSpec)
ctr, err := newContainer(ctx, r.hcs, id, rtSpec, opts.IO, r.sendEvent) ctr, err := newContainer(ctx, r.hcs, id, rtSpec, opts.IO)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -171,14 +169,3 @@ func (r *Runtime) Get(ctx context.Context, id string) (runtime.Task, error) {
} }
return c, nil return c, nil
} }
func (r *Runtime) sendEvent(id string, evType events.RuntimeEvent_EventType, pid, exitStatus uint32, exitedAt time.Time) {
r.events <- &events.RuntimeEvent{
Timestamp: time.Now(),
Type: evType,
Pid: pid,
ID: id,
ExitStatus: exitStatus,
ExitedAt: exitedAt,
}
}