api/services: define the container metadata service
Working from feedback on the existing implementation, we have now introduced a central metadata object to represent the lifecycle and pin the resources required to implement what people today know as containers. This includes the runtime specification and the root filesystem snapshots. We also allow arbitrary labeling of the container. Such provisions will bring the containerd definition of container closer to what is expected by users. The objects that encompass today's ContainerService, centered around the runtime, will be known as tasks. These tasks take on the existing lifecycle behavior of containerd's containers, which means that they are deleted when they exit. Largely, there are no other changes except for naming. The `Container` object will operate purely as a metadata object. No runtime state will be held on `Container`. It only informs the execution service on what is required for creating tasks and the resources in use by that container. The resources referenced by that container will be deleted when the container is deleted, if not in use. In this sense, users can create, list, label and delete containers in a similar way as they do with docker today, without the complexity of runtime locks that plagues current implementations. Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
@@ -2,6 +2,7 @@ package main
|
||||
|
||||
// register containerd builtins here
|
||||
import (
|
||||
_ "github.com/containerd/containerd/services/containers"
|
||||
_ "github.com/containerd/containerd/services/content"
|
||||
_ "github.com/containerd/containerd/services/diff"
|
||||
_ "github.com/containerd/containerd/services/execution"
|
||||
|
||||
@@ -17,6 +17,7 @@ import (
|
||||
"google.golang.org/grpc/health/grpc_health_v1"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
containersapi "github.com/containerd/containerd/api/services/containers"
|
||||
contentapi "github.com/containerd/containerd/api/services/content"
|
||||
diffapi "github.com/containerd/containerd/api/services/diff"
|
||||
api "github.com/containerd/containerd/api/services/execution"
|
||||
@@ -265,7 +266,7 @@ func resolveMetaDB(ctx *cli.Context) (*bolt.DB, error) {
|
||||
return db, nil
|
||||
}
|
||||
|
||||
func loadRuntimes(monitor plugin.ContainerMonitor) (map[string]plugin.Runtime, error) {
|
||||
func loadRuntimes(monitor plugin.TaskMonitor) (map[string]plugin.Runtime, error) {
|
||||
o := make(map[string]plugin.Runtime)
|
||||
for name, rr := range plugin.Registrations() {
|
||||
if rr.Type != plugin.RuntimePlugin {
|
||||
@@ -293,10 +294,10 @@ func loadRuntimes(monitor plugin.ContainerMonitor) (map[string]plugin.Runtime, e
|
||||
return o, nil
|
||||
}
|
||||
|
||||
func loadMonitor() (plugin.ContainerMonitor, error) {
|
||||
var monitors []plugin.ContainerMonitor
|
||||
func loadMonitor() (plugin.TaskMonitor, error) {
|
||||
var monitors []plugin.TaskMonitor
|
||||
for name, m := range plugin.Registrations() {
|
||||
if m.Type != plugin.ContainerMonitorPlugin {
|
||||
if m.Type != plugin.TaskMonitorPlugin {
|
||||
continue
|
||||
}
|
||||
log.G(global).Infof("loading monitor plugin %q...", name)
|
||||
@@ -309,12 +310,12 @@ func loadMonitor() (plugin.ContainerMonitor, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
monitors = append(monitors, mm.(plugin.ContainerMonitor))
|
||||
monitors = append(monitors, mm.(plugin.TaskMonitor))
|
||||
}
|
||||
if len(monitors) == 0 {
|
||||
return plugin.NewNoopMonitor(), nil
|
||||
}
|
||||
return plugin.NewMultiContainerMonitor(monitors...), nil
|
||||
return plugin.NewMultiTaskMonitor(monitors...), nil
|
||||
}
|
||||
|
||||
func loadSnapshotter(store content.Store) (snapshot.Snapshotter, error) {
|
||||
@@ -414,8 +415,10 @@ func interceptor(ctx gocontext.Context,
|
||||
) (interface{}, error) {
|
||||
ctx = log.WithModule(ctx, "containerd")
|
||||
switch info.Server.(type) {
|
||||
case api.ContainerServiceServer:
|
||||
case api.TasksServer:
|
||||
ctx = log.WithModule(ctx, "execution")
|
||||
case containersapi.ContainersServer:
|
||||
ctx = log.WithModule(ctx, "containers")
|
||||
case contentapi.ContentServer:
|
||||
ctx = log.WithModule(ctx, "content")
|
||||
case imagesapi.ImagesServer:
|
||||
|
||||
Reference in New Issue
Block a user