Refactor runtime events into Task* types
This removes the RuntimeEvent super proto with enums into separate runtime event protos to be inline with the other events that are output by containerd. This also renames the runtime events into Task* events. Fixes #1071 Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
parent
8f1c11d862
commit
2b6d790ff4
@ -11,7 +11,6 @@
|
||||
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/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/task.proto
|
||||
|
||||
@ -29,17 +28,19 @@
|
||||
NamespaceCreate
|
||||
NamespaceUpdate
|
||||
NamespaceDelete
|
||||
RuntimeIO
|
||||
RuntimeMount
|
||||
RuntimeCreate
|
||||
RuntimeEvent
|
||||
RuntimeDelete
|
||||
SnapshotPrepare
|
||||
SnapshotCommit
|
||||
SnapshotRemove
|
||||
TaskCreate
|
||||
TaskStart
|
||||
TaskDelete
|
||||
TaskIO
|
||||
TaskExit
|
||||
TaskOOM
|
||||
TaskExecAdded
|
||||
TaskPaused
|
||||
TaskResumed
|
||||
TaskCheckpointed
|
||||
*/
|
||||
package events
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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
@ -2,18 +2,67 @@ syntax = "proto3";
|
||||
|
||||
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";
|
||||
|
||||
message TaskCreate {
|
||||
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 {
|
||||
string container_id = 1;
|
||||
uint32 pid = 2;
|
||||
}
|
||||
|
||||
message TaskDelete {
|
||||
string container_id = 1;
|
||||
uint32 pid = 2;
|
||||
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;
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"text/tabwriter"
|
||||
|
||||
eventsapi "github.com/containerd/containerd/api/services/events/v1"
|
||||
@ -33,7 +33,11 @@ var eventsCommand = cli.Command{
|
||||
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 {
|
||||
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
|
||||
}
|
||||
|
@ -62,7 +62,6 @@ var shimCommand = cli.Command{
|
||||
shimCreateCommand,
|
||||
shimStartCommand,
|
||||
shimDeleteCommand,
|
||||
shimEventsCommand,
|
||||
shimStateCommand,
|
||||
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) {
|
||||
bindSocket := context.GlobalString("socket")
|
||||
if bindSocket == "" {
|
||||
|
@ -12,9 +12,7 @@ import (
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"github.com/boltdb/bolt"
|
||||
eventsapi "github.com/containerd/containerd/api/services/events/v1"
|
||||
"github.com/containerd/containerd/api/types"
|
||||
"github.com/containerd/containerd/events"
|
||||
client "github.com/containerd/containerd/linux/shim"
|
||||
shim "github.com/containerd/containerd/linux/shim/v1"
|
||||
"github.com/containerd/containerd/log"
|
||||
@ -92,7 +90,6 @@ func New(ic *plugin.InitContext) (interface{}, error) {
|
||||
runtime: cfg.Runtime,
|
||||
monitor: monitor.(runtime.TaskMonitor),
|
||||
tasks: newTaskList(),
|
||||
emitter: events.GetPoster(ic.Context),
|
||||
db: m.(*bolt.DB),
|
||||
address: ic.Address,
|
||||
}
|
||||
@ -118,7 +115,6 @@ type Runtime struct {
|
||||
|
||||
monitor runtime.TaskMonitor
|
||||
tasks *taskList
|
||||
emitter events.Poster
|
||||
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 {
|
||||
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
|
||||
}
|
||||
|
||||
@ -227,23 +200,15 @@ func (r *Runtime) Delete(ctx context.Context, c runtime.Task) (*runtime.Exit, er
|
||||
}
|
||||
r.tasks.delete(ctx, lc)
|
||||
|
||||
var (
|
||||
bundle = loadBundle(filepath.Join(r.root, namespace, lc.id), namespace)
|
||||
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 {
|
||||
bundle := loadBundle(filepath.Join(r.root, namespace, lc.id), namespace)
|
||||
if err := bundle.Delete(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &runtime.Exit{
|
||||
Status: rsp.ExitStatus,
|
||||
Timestamp: rsp.ExitedAt,
|
||||
Pid: rsp.Pid,
|
||||
}, bundle.Delete()
|
||||
}, nil
|
||||
}
|
||||
|
||||
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),
|
||||
}, 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
|
||||
}
|
||||
|
@ -12,7 +12,6 @@ import (
|
||||
"golang.org/x/net/context"
|
||||
"golang.org/x/sys/unix"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/metadata"
|
||||
)
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
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) {
|
||||
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)
|
||||
}
|
||||
|
||||
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 {
|
||||
Post(ctx context.Context, in *events.PostEventRequest, opts ...grpc.CallOption) (*google_protobuf.Empty, error)
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ func NewService(path, namespace, address string) (*Service, error) {
|
||||
s := &Service{
|
||||
path: path,
|
||||
processes: make(map[string]process),
|
||||
events: make(chan *events.RuntimeEvent, 4096),
|
||||
events: make(chan interface{}, 4096),
|
||||
namespace: namespace,
|
||||
context: context,
|
||||
}
|
||||
@ -69,9 +69,9 @@ type Service struct {
|
||||
bundle string
|
||||
mu sync.Mutex
|
||||
processes map[string]process
|
||||
events chan *events.RuntimeEvent
|
||||
events chan interface{}
|
||||
eventsMu sync.Mutex
|
||||
deferredEvent *events.RuntimeEvent
|
||||
deferredEvent interface{}
|
||||
namespace string
|
||||
context context.Context
|
||||
}
|
||||
@ -96,11 +96,18 @@ func (s *Service) Create(ctx context.Context, r *shimapi.CreateTaskRequest) (*sh
|
||||
ExitCh: make(chan int, 1),
|
||||
}
|
||||
reaper.Default.Register(pid, cmd)
|
||||
s.events <- &events.RuntimeEvent{
|
||||
Type: events.RuntimeEvent_CREATE,
|
||||
ID: r.ID,
|
||||
ContainerID: s.id,
|
||||
Pid: uint32(pid),
|
||||
s.events <- &events.TaskCreate{
|
||||
ContainerID: r.ID,
|
||||
Bundle: r.Bundle,
|
||||
Rootfs: r.Rootfs,
|
||||
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)
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
s.events <- &events.RuntimeEvent{
|
||||
Type: events.RuntimeEvent_START,
|
||||
ID: s.id,
|
||||
s.events <- &events.TaskStart{
|
||||
ContainerID: s.id,
|
||||
Pid: uint32(s.initProcess.Pid()),
|
||||
}
|
||||
@ -134,6 +139,12 @@ func (s *Service) Delete(ctx context.Context, r *google_protobuf.Empty) (*shimap
|
||||
s.mu.Lock()
|
||||
delete(s.processes, p.ID())
|
||||
s.mu.Unlock()
|
||||
s.events <- &events.TaskDelete{
|
||||
ContainerID: s.id,
|
||||
ExitStatus: uint32(p.Status()),
|
||||
ExitedAt: p.ExitedAt(),
|
||||
Pid: uint32(p.Pid()),
|
||||
}
|
||||
return &shimapi.DeleteResponse{
|
||||
ExitStatus: uint32(p.Status()),
|
||||
ExitedAt: p.ExitedAt(),
|
||||
@ -184,10 +195,9 @@ func (s *Service) Exec(ctx context.Context, r *shimapi.ExecProcessRequest) (*shi
|
||||
reaper.Default.Register(pid, cmd)
|
||||
s.processes[r.ID] = process
|
||||
|
||||
s.events <- &events.RuntimeEvent{
|
||||
Type: events.RuntimeEvent_EXEC_ADDED,
|
||||
ID: r.ID,
|
||||
s.events <- &events.TaskExecAdded{
|
||||
ContainerID: s.id,
|
||||
ExecID: r.ID,
|
||||
Pid: uint32(pid),
|
||||
}
|
||||
go s.waitExit(process, pid, cmd)
|
||||
@ -216,30 +226,6 @@ func (s *Service) ResizePty(ctx context.Context, r *shimapi.ResizePtyRequest) (*
|
||||
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) {
|
||||
if s.initProcess == nil {
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
s.events <- &events.RuntimeEvent{
|
||||
Type: events.RuntimeEvent_PAUSED,
|
||||
ID: s.id,
|
||||
s.events <- &events.TaskPaused{
|
||||
ContainerID: s.id,
|
||||
Timestamp: time.Now(),
|
||||
}
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
s.events <- &events.RuntimeEvent{
|
||||
Type: events.RuntimeEvent_RESUMED,
|
||||
ID: s.id,
|
||||
s.events <- &events.TaskResumed{
|
||||
ContainerID: s.id,
|
||||
Timestamp: time.Now(),
|
||||
}
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
s.events <- &events.RuntimeEvent{
|
||||
Type: events.RuntimeEvent_CHECKPOINTED,
|
||||
ID: s.id,
|
||||
s.events <- &events.TaskCheckpointed{
|
||||
ContainerID: s.id,
|
||||
Timestamp: time.Now(),
|
||||
}
|
||||
return empty, nil
|
||||
}
|
||||
@ -386,10 +363,9 @@ func (s *Service) waitExit(p process, pid int, cmd *reaper.Cmd) {
|
||||
p.Exited(status)
|
||||
|
||||
reaper.Default.Delete(pid)
|
||||
s.events <- &events.RuntimeEvent{
|
||||
Type: events.RuntimeEvent_EXIT,
|
||||
ID: p.ID(),
|
||||
s.events <- &events.TaskExit{
|
||||
ContainerID: s.id,
|
||||
ID: p.ID(),
|
||||
Pid: uint32(pid),
|
||||
ExitStatus: uint32(status),
|
||||
ExitedAt: p.ExitedAt(),
|
||||
@ -418,7 +394,7 @@ func (s *Service) forward(client poster) {
|
||||
if _, err := client.Post(s.context, &events.PostEventRequest{
|
||||
Envelope: &events.Envelope{
|
||||
Timestamp: time.Now(),
|
||||
Topic: "/runtime/" + getTopic(e),
|
||||
Topic: "/task/" + getTopic(e),
|
||||
Event: a,
|
||||
},
|
||||
}); err != nil {
|
||||
@ -427,18 +403,26 @@ func (s *Service) forward(client poster) {
|
||||
}
|
||||
}
|
||||
|
||||
func getTopic(e *events.RuntimeEvent) string {
|
||||
switch e.Type {
|
||||
case events.RuntimeEvent_CREATE:
|
||||
func getTopic(e interface{}) string {
|
||||
switch e.(type) {
|
||||
case *events.TaskCreate:
|
||||
return "task-create"
|
||||
case events.RuntimeEvent_START:
|
||||
case *events.TaskStart:
|
||||
return "task-start"
|
||||
case events.RuntimeEvent_EXEC_ADDED:
|
||||
return "task-execadded"
|
||||
case events.RuntimeEvent_OOM:
|
||||
case *events.TaskOOM:
|
||||
return "task-oom"
|
||||
case events.RuntimeEvent_EXIT:
|
||||
case *events.TaskExit:
|
||||
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 "?"
|
||||
}
|
||||
|
@ -24,7 +24,6 @@
|
||||
ListPidsResponse
|
||||
CheckpointTaskRequest
|
||||
ShimInfoResponse
|
||||
StreamEventsRequest
|
||||
UpdateTaskRequest
|
||||
*/
|
||||
package shim
|
||||
@ -38,7 +37,6 @@ import _ "github.com/gogo/protobuf/gogoproto"
|
||||
import _ "github.com/gogo/protobuf/types"
|
||||
import containerd_types "github.com/containerd/containerd/api/types"
|
||||
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"
|
||||
|
||||
@ -216,20 +214,13 @@ func (m *ShimInfoResponse) Reset() { *m = ShimInfoResponse{}
|
||||
func (*ShimInfoResponse) ProtoMessage() {}
|
||||
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 {
|
||||
Resources *google_protobuf.Any `protobuf:"bytes,1,opt,name=resources" json:"resources,omitempty"`
|
||||
}
|
||||
|
||||
func (m *UpdateTaskRequest) Reset() { *m = UpdateTaskRequest{} }
|
||||
func (*UpdateTaskRequest) ProtoMessage() {}
|
||||
func (*UpdateTaskRequest) Descriptor() ([]byte, []int) { return fileDescriptorShim, []int{16} }
|
||||
func (*UpdateTaskRequest) Descriptor() ([]byte, []int) { return fileDescriptorShim, []int{15} }
|
||||
|
||||
func init() {
|
||||
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((*CheckpointTaskRequest)(nil), "containerd.runtime.linux.shim.v1.CheckpointTaskRequest")
|
||||
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")
|
||||
}
|
||||
|
||||
@ -272,7 +262,6 @@ type ShimClient interface {
|
||||
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)
|
||||
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)
|
||||
Exec(ctx context.Context, in *ExecProcessRequest, opts ...grpc.CallOption) (*ExecProcessResponse, 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
|
||||
}
|
||||
|
||||
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) {
|
||||
out := new(google_protobuf1.Empty)
|
||||
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)
|
||||
Resume(context.Context, *google_protobuf1.Empty) (*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)
|
||||
Exec(context.Context, *ExecProcessRequest) (*ExecProcessResponse, 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)
|
||||
}
|
||||
|
||||
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) {
|
||||
in := new(KillRequest)
|
||||
if err := dec(in); err != nil {
|
||||
@ -840,13 +775,7 @@ var _Shim_serviceDesc = grpc.ServiceDesc{
|
||||
Handler: _Shim_Update_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{
|
||||
{
|
||||
StreamName: "Stream",
|
||||
Handler: _Shim_Stream_Handler,
|
||||
ServerStreams: true,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
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
|
||||
}
|
||||
|
||||
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) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
@ -1762,12 +1673,6 @@ func (m *ShimInfoResponse) Size() (n int) {
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *StreamEventsRequest) Size() (n int) {
|
||||
var l int
|
||||
_ = l
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *UpdateTaskRequest) Size() (n int) {
|
||||
var l int
|
||||
_ = l
|
||||
@ -1971,15 +1876,6 @@ func (this *ShimInfoResponse) String() string {
|
||||
}, "")
|
||||
return s
|
||||
}
|
||||
func (this *StreamEventsRequest) String() string {
|
||||
if this == nil {
|
||||
return "nil"
|
||||
}
|
||||
s := strings.Join([]string{`&StreamEventsRequest{`,
|
||||
`}`,
|
||||
}, "")
|
||||
return s
|
||||
}
|
||||
func (this *UpdateTaskRequest) String() string {
|
||||
if this == nil {
|
||||
return "nil"
|
||||
@ -3956,56 +3852,6 @@ func (m *ShimInfoResponse) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
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 {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
@ -4199,75 +4045,71 @@ func init() {
|
||||
}
|
||||
|
||||
var fileDescriptorShim = []byte{
|
||||
// 1117 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x57, 0x4d, 0x6f, 0xdb, 0x46,
|
||||
0x13, 0x36, 0xf5, 0x41, 0xc9, 0xa3, 0x57, 0x7e, 0xed, 0x8d, 0xe3, 0x32, 0x0a, 0x20, 0x0b, 0x3c,
|
||||
0xb8, 0x2a, 0x82, 0x90, 0xb1, 0xdc, 0x24, 0xfd, 0x00, 0x0a, 0xd8, 0x8e, 0x51, 0x18, 0xad, 0x11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3f, 0xca, 0xf6,
|
||||
0x20, 0x97, 0x2d, 0xc5, 0xd1, 0x25, 0xe9, 0x62, 0x6a, 0xe3, 0x4b, 0xec, 0x33, 0xca, 0x13, 0x39,
|
||||
0xce, 0x98, 0xb8, 0xc6, 0xfc, 0xa7, 0x00, 0x6b, 0xfb, 0x11, 0x76, 0x19, 0x7e, 0xe5, 0xd2, 0x0b,
|
||||
0x07, 0xbf, 0x89, 0x31, 0x65, 0x68, 0x03, 0x0a, 0xc4, 0x33, 0xb4, 0x96, 0xd6, 0x5e, 0xde, 0xd3,
|
||||
0x47, 0x6f, 0x37, 0x0b, 0x87, 0x2f, 0x9c, 0x02, 0xf1, 0xd0, 0x06, 0xe8, 0x67, 0xb1, 0xef, 0x0d,
|
||||
0xb0, 0x51, 0xe0, 0x67, 0x8e, 0x92, 0x90, 0x01, 0x15, 0x75, 0xad, 0x51, 0x14, 0x07, 0x63, 0x11,
|
||||
0xd9, 0xa0, 0x47, 0x41, 0xc0, 0xce, 0xa9, 0x51, 0x6a, 0x15, 0xdb, 0xb5, 0xce, 0x7b, 0x56, 0x02,
|
||||
0x3c, 0x11, 0x99, 0x75, 0xc4, 0x33, 0xe2, 0x28, 0x35, 0xd4, 0x80, 0x2a, 0xc3, 0xd1, 0x90, 0xf8,
|
||||
0xee, 0xc0, 0x28, 0xb7, 0xb4, 0x76, 0xd5, 0xb9, 0x95, 0xd1, 0x3a, 0x94, 0x29, 0xf3, 0x88, 0x6f,
|
||||
0xe8, 0xe2, 0x23, 0x52, 0xe0, 0x4e, 0x51, 0xe6, 0x05, 0x31, 0x33, 0x2a, 0xd2, 0x29, 0x29, 0xa9,
|
||||
0x7d, 0x1c, 0x45, 0x46, 0xf5, 0x76, 0x1f, 0x47, 0x11, 0x6a, 0x02, 0x74, 0xfb, 0xb8, 0x7b, 0x11,
|
||||
0x06, 0xc4, 0x67, 0xc6, 0xb2, 0x38, 0x4b, 0xec, 0xa0, 0x47, 0xb0, 0x16, 0xba, 0x11, 0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x05, 0xe7, 0x1b, 0x58,
|
||||
0x75, 0x30, 0x25, 0x3f, 0xe2, 0x63, 0x76, 0x9d, 0x15, 0xe0, 0x3a, 0x94, 0x7f, 0x20, 0x1e, 0xeb,
|
||||
0x2b, 0x74, 0xa4, 0xc0, 0x9d, 0xed, 0x63, 0xd2, 0xeb, 0x4b, 0x54, 0xea, 0x8e, 0x92, 0xcc, 0x2d,
|
||||
0xf8, 0x1f, 0x87, 0x0e, 0x67, 0x65, 0xf9, 0x6f, 0x0d, 0xea, 0x4a, 0x51, 0x79, 0xb9, 0x68, 0xc9,
|
||||
0xaa, 0xa8, 0x8a, 0x13, 0x36, 0xed, 0xf0, 0x04, 0x0a, 0x22, 0xf1, 0xc4, 0xae, 0x74, 0x1e, 0x26,
|
||||
0x4b, 0xf5, 0x72, 0x5b, 0x55, 0xab, 0x64, 0x96, 0xa3, 0x54, 0x27, 0x18, 0x95, 0xef, 0xc6, 0x48,
|
||||
0x4f, 0xc1, 0xa8, 0x32, 0x85, 0x51, 0x92, 0x05, 0xd5, 0x69, 0x16, 0x98, 0x2f, 0xa1, 0xf6, 0x05,
|
||||
0x19, 0x0c, 0x72, 0xb4, 0x26, 0x4a, 0x7a, 0x63, 0x1a, 0xd5, 0x1d, 0x25, 0xf1, 0x38, 0xdd, 0xc1,
|
||||
0x40, 0xc4, 0x59, 0x75, 0xf8, 0xd2, 0xfc, 0x0c, 0x56, 0xf6, 0x07, 0x01, 0xc5, 0x87, 0x2f, 0x73,
|
||||
0x60, 0x27, 0x83, 0x93, 0xcc, 0x94, 0x82, 0xf9, 0x01, 0xfc, 0xff, 0x4b, 0x42, 0xd9, 0x31, 0xf1,
|
||||
0x32, 0x8b, 0x61, 0x0b, 0x56, 0x27, 0xaa, 0x0a, 0x28, 0x04, 0xa5, 0x90, 0x78, 0xd4, 0xd0, 0x5a,
|
||||
0xc5, 0x76, 0xdd, 0x11, 0x6b, 0xf3, 0x3b, 0xb8, 0x3f, 0xe9, 0x29, 0xc9, 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d8, 0x3f, 0x76, 0x9f, 0xf2, 0xdf, 0x33, 0x5d, 0x5c, 0xbf, 0xf3, 0x6f,
|
||||
0x00, 0x00, 0x00, 0xff, 0xff, 0x8d, 0x23, 0x98, 0xb4, 0x16, 0x0e, 0x00, 0x00,
|
||||
// 1049 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x57, 0x4f, 0x6f, 0xe3, 0x44,
|
||||
0x14, 0x5f, 0xe7, 0xaf, 0xfb, 0x42, 0x4a, 0x3b, 0x94, 0xe2, 0xcd, 0x4a, 0x69, 0xe4, 0x43, 0x09,
|
||||
0x42, 0x6b, 0xd3, 0x14, 0x76, 0xf9, 0x23, 0x21, 0xb5, 0xdd, 0x15, 0xaa, 0xa0, 0xda, 0xca, 0xdd,
|
||||
0x05, 0x04, 0x42, 0x95, 0x1b, 0x4f, 0x93, 0x51, 0x1d, 0x8f, 0xd7, 0x33, 0x2e, 0x2d, 0x27, 0x4e,
|
||||
0x9c, 0xf9, 0x38, 0x7c, 0x84, 0x1e, 0x91, 0xb8, 0x70, 0x5a, 0xd8, 0x9c, 0xb8, 0xf0, 0x1d, 0xd0,
|
||||
0x8c, 0x27, 0x8d, 0x93, 0xd4, 0xb2, 0xc3, 0xa5, 0x9e, 0x37, 0xf3, 0x7b, 0x33, 0xef, 0xcd, 0xef,
|
||||
0xcd, 0xef, 0x35, 0xf0, 0xc9, 0x80, 0xf0, 0x61, 0x7c, 0x66, 0xf5, 0xe9, 0xc8, 0xee, 0xd3, 0x80,
|
||||
0xbb, 0x24, 0xc0, 0x91, 0x97, 0x1e, 0xfa, 0x24, 0x88, 0xaf, 0x6c, 0x36, 0x24, 0x23, 0xfb, 0x72,
|
||||
0x47, 0x7e, 0xad, 0x30, 0xa2, 0x9c, 0xa2, 0xce, 0x14, 0x64, 0x45, 0x71, 0xc0, 0xc9, 0x08, 0x5b,
|
||||
0x12, 0x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x16, 0x6c,
|
||||
0x24, 0x71, 0x1c, 0x47, 0xb4, 0x8f, 0x19, 0xcb, 0x29, 0x11, 0xf3, 0x37, 0x0d, 0xd0, 0xd3, 0x2b,
|
||||
0xdc, 0x2f, 0x06, 0x9f, 0xa1, 0xbb, 0x94, 0x45, 0x77, 0xf9, 0x6e, 0xba, 0x2b, 0x19, 0x74, 0x57,
|
||||
0x67, 0xe8, 0xee, 0x42, 0x85, 0x85, 0xb8, 0x2f, 0x6b, 0x26, 0x8b, 0x1e, 0x89, 0x30, 0xdf, 0x85,
|
||||
0xb7, 0x66, 0x22, 0xcf, 0x24, 0xe7, 0x5b, 0x58, 0x73, 0x30, 0x23, 0x3f, 0xe1, 0x63, 0x7e, 0x9d,
|
||||
0x97, 0xe0, 0x06, 0x54, 0x7f, 0x24, 0x1e, 0x1f, 0x2a, 0x76, 0x12, 0x43, 0x04, 0x3b, 0xc4, 0x64,
|
||||
0x30, 0x4c, 0x58, 0x69, 0x3a, 0xca, 0x32, 0xb7, 0xe1, 0x0d, 0x41, 0x1d, 0xce, 0xbb, 0xe5, 0x7f,
|
||||
0x34, 0x68, 0x2a, 0xa0, 0x8a, 0x72, 0xd9, 0x27, 0xab, 0xb2, 0x2a, 0x4f, 0xab, 0x69, 0x57, 0x5c,
|
||||
0xa0, 0x2c, 0x24, 0x71, 0xb1, 0xab, 0xbd, 0x07, 0xe9, 0xa7, 0x7a, 0xb9, 0xa3, 0x5e, 0x6b, 0x52,
|
||||
0x59, 0x8e, 0x82, 0x4e, 0x39, 0xaa, 0xde, 0xcd, 0x51, 0x2d, 0x83, 0xa3, 0xfa, 0x0c, 0x47, 0xe9,
|
||||
0x2a, 0xd0, 0x67, 0xab, 0xc0, 0x7c, 0x06, 0x8d, 0x2f, 0x89, 0xef, 0x17, 0x90, 0x26, 0x46, 0x06,
|
||||
0x93, 0x32, 0x6a, 0x3a, 0xca, 0x12, 0x79, 0xba, 0xbe, 0x2f, 0xf3, 0xd4, 0x1d, 0x31, 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b, 0x7b, 0xdc, 0xd6, 0xbe, 0xdb,
|
||||
0x5d, 0xee, 0xa7, 0xd0, 0x67, 0xe2, 0x7b, 0x56, 0x93, 0xdb, 0xef, 0xfe, 0x17, 0x00, 0x00, 0xff,
|
||||
0xff, 0xa3, 0x6e, 0xef, 0x88, 0x48, 0x0d, 0x00, 0x00,
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ import "gogoproto/gogo.proto";
|
||||
import "google/protobuf/timestamp.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/services/events/v1/runtime.proto";
|
||||
|
||||
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 Stream(StreamEventsRequest) returns (stream containerd.services.events.v1.RuntimeEvent);
|
||||
|
||||
rpc Kill(KillRequest) returns (google.protobuf.Empty);
|
||||
|
||||
rpc Exec(ExecProcessRequest) returns (ExecProcessResponse);
|
||||
@ -142,9 +139,6 @@ message ShimInfoResponse {
|
||||
uint32 shim_pid = 1;
|
||||
}
|
||||
|
||||
message StreamEventsRequest {
|
||||
}
|
||||
|
||||
message UpdateTaskRequest {
|
||||
google.protobuf.Any resources = 1;
|
||||
}
|
||||
|
@ -3,8 +3,6 @@
|
||||
package cgroups
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/containerd/cgroups"
|
||||
events "github.com/containerd/containerd/api/services/events/v1"
|
||||
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) {
|
||||
if err := m.emitter.Post(m.context, &events.RuntimeEvent{
|
||||
Timestamp: time.Now(),
|
||||
Type: events.RuntimeEvent_OOM,
|
||||
ID: id,
|
||||
if err := m.emitter.Post(m.context, &events.TaskOOM{
|
||||
ContainerID: id,
|
||||
}); err != nil {
|
||||
log.G(m.context).WithError(err).Error("post OOM event")
|
||||
|
@ -65,21 +65,17 @@ func (p *process) Wait(ctx context.Context) (uint32, error) {
|
||||
if err != nil {
|
||||
return UnknownExitStatus, err
|
||||
}
|
||||
evloop:
|
||||
for {
|
||||
evt, err := eventstream.Recv()
|
||||
if err != nil {
|
||||
return UnknownExitStatus, err
|
||||
}
|
||||
if typeurl.Is(evt.Event, &eventsapi.RuntimeEvent{}) {
|
||||
if typeurl.Is(evt.Event, &eventsapi.TaskExit{}) {
|
||||
v, err := typeurl.UnmarshalAny(evt.Event)
|
||||
if err != nil {
|
||||
return UnknownExitStatus, err
|
||||
}
|
||||
e := v.(*eventsapi.RuntimeEvent)
|
||||
if e.Type != eventsapi.RuntimeEvent_EXIT {
|
||||
continue evloop
|
||||
}
|
||||
e := v.(*eventsapi.TaskExit)
|
||||
if e.ID == p.id && e.ContainerID == p.task.id {
|
||||
return e.ExitStatus, nil
|
||||
}
|
||||
|
9
task.go
9
task.go
@ -153,16 +153,13 @@ func (t *task) Wait(ctx context.Context) (uint32, error) {
|
||||
if err != nil {
|
||||
return UnknownExitStatus, err
|
||||
}
|
||||
if typeurl.Is(evt.Event, &eventsapi.RuntimeEvent{}) {
|
||||
if typeurl.Is(evt.Event, &eventsapi.TaskExit{}) {
|
||||
v, err := typeurl.UnmarshalAny(evt.Event)
|
||||
if err != nil {
|
||||
return UnknownExitStatus, err
|
||||
}
|
||||
e := v.(*eventsapi.RuntimeEvent)
|
||||
if e.Type != eventsapi.RuntimeEvent_EXIT {
|
||||
continue
|
||||
}
|
||||
if e.ID == t.id && e.Pid == t.pid {
|
||||
e := v.(*eventsapi.TaskExit)
|
||||
if e.ContainerID == t.id && e.Pid == t.pid {
|
||||
return e.ExitStatus, nil
|
||||
}
|
||||
}
|
||||
|
@ -7,9 +7,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
events "github.com/containerd/containerd/api/services/events/v1"
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/containerd/containerd/runtime"
|
||||
"github.com/containerd/containerd/windows/hcs"
|
||||
@ -21,9 +19,7 @@ import (
|
||||
|
||||
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, sendEvent eventCallback) ([]*container, error) {
|
||||
func loadContainers(ctx context.Context, h *hcs.HCS) ([]*container, error) {
|
||||
hCtr, err := h.LoadContainers(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -32,16 +28,15 @@ func loadContainers(ctx context.Context, h *hcs.HCS, sendEvent eventCallback) ([
|
||||
containers := make([]*container, 0)
|
||||
for _, c := range hCtr {
|
||||
containers = append(containers, &container{
|
||||
ctr: c,
|
||||
status: runtime.RunningStatus,
|
||||
sendEvent: sendEvent,
|
||||
ctr: c,
|
||||
status: runtime.RunningStatus,
|
||||
})
|
||||
}
|
||||
|
||||
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)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -51,21 +46,19 @@ func newContainer(ctx context.Context, h *hcs.HCS, id string, spec *RuntimeSpec,
|
||||
if err != nil {
|
||||
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{
|
||||
ctr: hcsCtr,
|
||||
status: runtime.CreatedStatus,
|
||||
sendEvent: sendEvent,
|
||||
ctr: hcsCtr,
|
||||
status: runtime.CreatedStatus,
|
||||
}, nil
|
||||
}
|
||||
|
||||
type container struct {
|
||||
sync.Mutex
|
||||
|
||||
ctr *hcs.Container
|
||||
status runtime.Status
|
||||
sendEvent eventCallback
|
||||
ctr *hcs.Container
|
||||
status runtime.Status
|
||||
}
|
||||
|
||||
func (c *container) ID() string {
|
||||
@ -90,16 +83,16 @@ func (c *container) Start(ctx context.Context) error {
|
||||
}
|
||||
|
||||
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
|
||||
go func() {
|
||||
ec, err := c.ctr.ExitCode()
|
||||
_, err := c.ctr.ExitCode()
|
||||
if err != nil {
|
||||
log.G(ctx).Debug(err)
|
||||
}
|
||||
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
|
||||
@ -163,11 +156,11 @@ func (c *container) Exec(ctx context.Context, id string, opts runtime.ExecOpts)
|
||||
}
|
||||
|
||||
go func() {
|
||||
ec, err := p.ExitCode()
|
||||
_, err := p.ExitCode()
|
||||
if err != nil {
|
||||
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
|
||||
|
@ -8,9 +8,7 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
events "github.com/containerd/containerd/api/services/events/v1"
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/containerd/containerd/plugin"
|
||||
"github.com/containerd/containerd/runtime"
|
||||
@ -47,7 +45,7 @@ func New(ic *plugin.InitContext) (interface{}, error) {
|
||||
r := &Runtime{
|
||||
pidPool: pid.NewPool(),
|
||||
containers: make(map[string]*container),
|
||||
events: make(chan *events.RuntimeEvent, 2048),
|
||||
events: make(chan interface{}, 2048),
|
||||
eventsContext: c,
|
||||
eventsCancel: cancel,
|
||||
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
|
||||
// support restoring containers
|
||||
ctrs, err := loadContainers(ic.Context, r.hcs, r.sendEvent)
|
||||
ctrs, err := loadContainers(ic.Context, r.hcs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, c := range ctrs {
|
||||
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
|
||||
@ -90,7 +88,7 @@ type Runtime struct {
|
||||
|
||||
containers map[string]*container
|
||||
|
||||
events chan *events.RuntimeEvent
|
||||
events chan interface{}
|
||||
eventsContext context.Context
|
||||
eventsCancel func()
|
||||
}
|
||||
@ -113,7 +111,7 @@ func (r *Runtime) Create(ctx context.Context, id string, opts runtime.CreateOpts
|
||||
return nil, err
|
||||
}
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
@ -171,14 +169,3 @@ func (r *Runtime) Get(ctx context.Context, id string) (runtime.Task, error) {
|
||||
}
|
||||
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,
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user