diff --git a/.travis.yml b/.travis.yml index 538229d..09584ef 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,6 @@ sudo: required language: go go: - - 1.7.x - 1.8.x - tip diff --git a/design/plugins.md b/design/plugins.md index c681880..009f4d7 100644 --- a/design/plugins.md +++ b/design/plugins.md @@ -1,6 +1,6 @@ # containerd Plugin Model -With go 1.8 we now have dynamically loaded plugins via go packages. This seems to be a very easy and clean way to extent containerd. It does have the drawback of only working on Linux right now but there is where we see the most need for swapping out defaults. +With go 1.8 we now have dynamically loaded plugins via go packages. This seems to be a very easy and clean way to extend containerd. It does have the drawback of only working on Linux right now but this is where we see the most need for swapping out defaults. ## core @@ -19,44 +19,11 @@ The core should be comprised of the following: The runtime code in the core provides API to create, list, and manage containers on the system. It provides a runtime type that is responsible for creating, deleting, and loading containers. -```go -type Runtime interface { - Create(ctx context.Context, id string, opts CreateOpts) (Container, error) - Containers() ([]Container, error) - Delete(ctx context.Context, c Container) error -} -``` - -There is a common `Container` interface with common methods for interacting with the container as well as platform specific container interfaces. - - -```go -type Container interface { - Info() ContainerInfo - Start(context.Context) error - State(context.Context) (State, error) - Events(context.Context) (<-chan ContainerEvent, error) - Kill(context.Context) error -} - -type LinuxContainer interface { - Pause(context.Context) error - Resume(context.Context) error - Exec(context.Context, ExecOpts) (uint32, error) - Signal(c context.Context, pid uint32, s os.Signal) error -} - -type WindowsContainer interface { - Exec(context.Context, ExecOpts) (uint32, error) - Signal(c context.Context, pid uint32, s os.Signal) error -} -``` - ### Monitoring The monitoring subsystem is a way to collect events and metrics from various subsystems. With the monitoring subsystem you can monitor various types, subsystems, and objects within the core. -This can be use to collect metrics for containers and monitor OOM events when supported. +This can be used to collect metrics for containers and monitor OOM events when supported. An example of this is a prometheus monitor that exports container metrics such as cpu, memory, io, and network information. ```go diff --git a/linux/main.go b/linux/main.go new file mode 100644 index 0000000..3c21764 --- /dev/null +++ b/linux/main.go @@ -0,0 +1,5 @@ +package main + +func main() { + panic("build as plugin not executable") +} diff --git a/linux/runtime.go b/linux/runtime.go index 85faa64..3ca5930 100644 --- a/linux/runtime.go +++ b/linux/runtime.go @@ -31,12 +31,13 @@ func init() { } func New(ic *containerd.InitContext) (interface{}, error) { - if err := os.MkdirAll(ic.State, 0700); err != nil { + path := filepath.Join(ic.State, runtimeName) + if err := os.MkdirAll(path, 0700); err != nil { return nil, err } c, cancel := context.WithCancel(ic.Context) return &Runtime{ - root: ic.State, + root: path, events: make(chan *containerd.Event, 2048), eventsContext: c, eventsCancel: cancel, diff --git a/plugin.go b/plugin.go index 7397b39..6ae63ef 100644 --- a/plugin.go +++ b/plugin.go @@ -46,13 +46,13 @@ var register = struct { r: make(map[string]*Registration), } -// Load loads all plugins at the provided that into containerd +// Load loads all plugins at the provided path into containerd func Load(path string) (err error) { defer func() { if v := recover(); v != nil { rerr, ok := v.(error) if !ok { - panic(v) + rerr = fmt.Errorf("%s", v) } err = rerr } diff --git a/services/execution/service.go b/services/execution/service.go index 7661b24..42e25ea 100644 --- a/services/execution/service.go +++ b/services/execution/service.go @@ -133,6 +133,8 @@ func (s *Service) Delete(ctx context.Context, r *api.DeleteRequest) (*google_pro func (s *Service) List(ctx context.Context, r *api.ListRequest) (*api.ListResponse, error) { resp := &api.ListResponse{} + s.mu.Lock() + defer s.mu.Unlock() for _, c := range s.containers { state, err := c.State(ctx) if err != nil {