Skip to content

api: converge events subsystem #785

@stevvooe

Description

@stevvooe

Currently, the ContainerService has an Events method that emits events for container lifecycle operations. The intent of this issue is to bring that event system to the wider subsystems.

The current Event type is specific to execution related use cases.

We also have a package to allow the emission of events through a common, context-based interface. Event emitters should leverage this interface to decouple the event emission code from event propagation. We should make it easy to setup a context with an event emitter that allows all subsystems to send out events.

The key to this work is defining a common envelope for emitting events. The current type, events.Envelope defines some of the necessary parts but we'll need to define a protobuf version, as well. We can start with something like this:

type Envelope struct {
  Timestamp time.Time
  Topic string // defines slash-oriented topic-heirarchy
  Event interface{}
}

We can match this with a protobuf type as follows:

message Envelope {
  Timestamp timestamp = 1;
  string topic = 2;
  google.protobuf.Any event = 3;
}

Events can be filtered by topic. Let's say we have the following topics:

/service/container/exit
/service/container/oom
/service/content/write
/service/image/register
/plugin/register
/plugin/error

One could select all events from services with the following event filter, based on glob matching:

/service/**

If you want to know which plugins are registered, you could push in a filter like this:

/plugin/register

Effectively, we can control which aspects of an event can be filtered by selecting the topic in which it is published. Understanding the behavior of containerd from a consumer can be done by selecting one or more of these topics.

Tasks:

  • Define common Events service
  • Define event envelope to hold subsystem specific events.
  • Port the ContainerService events to use the new service
  • Add support from various other subsystems
    • Image Service
    • Content Service
    • Rootfs Service

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions