Move libcontainer to linux pkg

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby 2015-12-01 12:00:11 -08:00
parent c24abdde1b
commit b823ce9149
4 changed files with 18 additions and 10 deletions

View file

@ -13,11 +13,9 @@ var (
ErrUnknownEvent = errors.New("containerd: unknown event type") ErrUnknownEvent = errors.New("containerd: unknown event type")
// Internal errors // Internal errors
errShutdown = errors.New("containerd: supervisor is shutdown") errShutdown = errors.New("containerd: supervisor is shutdown")
errRootNotAbs = errors.New("containerd: rootfs path is not an absolute path") errRootNotAbs = errors.New("containerd: rootfs path is not an absolute path")
errNoContainerForPid = errors.New("containerd: pid not registered for any container") errNoContainerForPid = errors.New("containerd: pid not registered for any container")
errInvalidContainerType = errors.New("containerd: invalid container type for runtime")
errNotChildProcess = errors.New("containerd: not a child process for container")
// internal error where the handler will defer to another for the final response // internal error where the handler will defer to another for the final response
// //
// TODO: we could probably do a typed error with another error channel for this to make it // TODO: we could probably do a typed error with another error channel for this to make it

View file

@ -1,6 +1,6 @@
// +build libcontainer // +build libcontainer
package containerd package linux
import ( import (
"encoding/json" "encoding/json"
@ -254,7 +254,7 @@ func (c *libcontainerContainer) Processes() ([]runtime.Process, error) {
func (c *libcontainerContainer) RemoveProcess(pid int) error { func (c *libcontainerContainer) RemoveProcess(pid int) error {
if _, ok := c.additionalProcesses[pid]; !ok { if _, ok := c.additionalProcesses[pid]; !ok {
return errNotChildProcess return runtime.ErrNotChildProcess
} }
delete(c.additionalProcesses, pid) delete(c.additionalProcesses, pid)
return nil return nil
@ -312,7 +312,7 @@ func (r *libcontainerRuntime) Create(id, bundlePath string, stdio *runtime.Stdio
func (r *libcontainerRuntime) StartProcess(ci runtime.Container, p specs.Process, stdio *runtime.Stdio) (runtime.Process, error) { func (r *libcontainerRuntime) StartProcess(ci runtime.Container, p specs.Process, stdio *runtime.Stdio) (runtime.Process, error) {
c, ok := ci.(*libcontainerContainer) c, ok := ci.(*libcontainerContainer)
if !ok { if !ok {
return nil, errInvalidContainerType return nil, runtime.ErrInvalidContainerType
} }
process, err := r.newProcess(p, stdio) process, err := r.newProcess(p, stdio)
if err != nil { if err != nil {

View file

@ -1,6 +1,15 @@
package runtime package runtime
import "github.com/opencontainers/specs" import (
"errors"
"github.com/opencontainers/specs"
)
var (
ErrNotChildProcess = errors.New("containerd: not a child process for container")
ErrInvalidContainerType = errors.New("containerd: invalid container type for runtime")
)
// runtime handles containers, containers handle their own actions. // runtime handles containers, containers handle their own actions.
type Runtime interface { type Runtime interface {

View file

@ -8,6 +8,7 @@ import (
"time" "time"
"github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
"github.com/docker/containerd/linux"
"github.com/docker/containerd/runtime" "github.com/docker/containerd/runtime"
"github.com/opencontainers/runc/libcontainer" "github.com/opencontainers/runc/libcontainer"
) )
@ -18,7 +19,7 @@ func NewSupervisor(stateDir string, concurrency int) (*Supervisor, error) {
return nil, err return nil, err
} }
// register counters // register counters
r, err := NewRuntime(stateDir) r, err := linux.NewRuntime(stateDir)
if err != nil { if err != nil {
return nil, err return nil, err
} }