events: move types into service package
When using events, it was found to be fairly unwieldy with a number of extra packages. For the most part, when interacting with the events service, we want types of the same version of the service. This has been accomplished by moving all events types into the events package. In addition, several fixes to the way events are marshaled have been included. Specifically, we defer to the protobuf type registration system to assemble events and type urls, with a little bit sheen on top of add a containerd.io oriented namespace. This has resulted in much cleaner event consumption and has removed the reliance on error prone type urls, in favor of concrete types. Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
@@ -16,8 +16,8 @@ import (
|
||||
|
||||
"google.golang.org/grpc"
|
||||
|
||||
eventsapi "github.com/containerd/containerd/api/services/events/v1"
|
||||
"github.com/containerd/containerd/api/services/shim/v1"
|
||||
"github.com/containerd/containerd/api/types/event"
|
||||
"github.com/containerd/containerd/api/types/mount"
|
||||
"github.com/containerd/containerd/api/types/task"
|
||||
"github.com/containerd/containerd/events"
|
||||
@@ -242,19 +242,19 @@ func (r *Runtime) Create(ctx context.Context, id string, opts plugin.CreateOpts)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var runtimeMounts []*event.RuntimeMount
|
||||
var runtimeMounts []*eventsapi.RuntimeMount
|
||||
for _, m := range opts.Rootfs {
|
||||
runtimeMounts = append(runtimeMounts, &event.RuntimeMount{
|
||||
runtimeMounts = append(runtimeMounts, &eventsapi.RuntimeMount{
|
||||
Type: m.Type,
|
||||
Source: m.Source,
|
||||
Options: m.Options,
|
||||
})
|
||||
}
|
||||
if err := r.emit(ctx, "/runtime/create", event.RuntimeCreate{
|
||||
if err := r.emit(ctx, "/runtime/create", &eventsapi.RuntimeCreate{
|
||||
ID: id,
|
||||
Bundle: path,
|
||||
RootFS: runtimeMounts,
|
||||
IO: &event.RuntimeIO{
|
||||
IO: &eventsapi.RuntimeIO{
|
||||
Stdin: opts.IO.Stdin,
|
||||
Stdout: opts.IO.Stdout,
|
||||
Stderr: opts.IO.Stderr,
|
||||
@@ -290,7 +290,7 @@ func (r *Runtime) Delete(ctx context.Context, c plugin.Task) (*plugin.Exit, erro
|
||||
r.tasks.delete(ctx, lc)
|
||||
|
||||
i := c.Info()
|
||||
if err := r.emit(ctx, "/runtime/delete", event.RuntimeDelete{
|
||||
if err := r.emit(ctx, "/runtime/delete", &eventsapi.RuntimeDelete{
|
||||
ID: i.ID,
|
||||
Runtime: i.Runtime,
|
||||
ExitStatus: rsp.ExitStatus,
|
||||
@@ -416,7 +416,7 @@ func (r *Runtime) forward(ctx context.Context, events shim.Shim_EventsClient) {
|
||||
ExitStatus: e.ExitStatus,
|
||||
ExitedAt: e.ExitedAt,
|
||||
}
|
||||
if err := r.emit(ctx, "/runtime/"+topic, event.RuntimeEvent{
|
||||
if err := r.emit(ctx, "/runtime/"+topic, &eventsapi.RuntimeEvent{
|
||||
ID: e.ID,
|
||||
Type: e.Type,
|
||||
Pid: e.Pid,
|
||||
|
Reference in New Issue
Block a user