diff --git a/errors.go b/errors.go index d1cf2d0..7e7eb42 100644 --- a/errors.go +++ b/errors.go @@ -13,11 +13,9 @@ var ( ErrUnknownEvent = errors.New("containerd: unknown event type") // Internal errors - errShutdown = errors.New("containerd: supervisor is shutdown") - errRootNotAbs = errors.New("containerd: rootfs path is not an absolute path") - 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") + errShutdown = errors.New("containerd: supervisor is shutdown") + errRootNotAbs = errors.New("containerd: rootfs path is not an absolute path") + errNoContainerForPid = errors.New("containerd: pid not registered for any container") // 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 diff --git a/runtime_linux.go b/linux/linux.go similarity index 99% rename from runtime_linux.go rename to linux/linux.go index 5a3ad1a..e902fa6 100644 --- a/runtime_linux.go +++ b/linux/linux.go @@ -1,6 +1,6 @@ // +build libcontainer -package containerd +package linux import ( "encoding/json" @@ -254,7 +254,7 @@ func (c *libcontainerContainer) Processes() ([]runtime.Process, error) { func (c *libcontainerContainer) RemoveProcess(pid int) error { if _, ok := c.additionalProcesses[pid]; !ok { - return errNotChildProcess + return runtime.ErrNotChildProcess } delete(c.additionalProcesses, pid) 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) { c, ok := ci.(*libcontainerContainer) if !ok { - return nil, errInvalidContainerType + return nil, runtime.ErrInvalidContainerType } process, err := r.newProcess(p, stdio) if err != nil { diff --git a/runtime/runtime.go b/runtime/runtime.go index 02c86db..0af71e9 100644 --- a/runtime/runtime.go +++ b/runtime/runtime.go @@ -1,6 +1,15 @@ 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. type Runtime interface { diff --git a/supervisor.go b/supervisor.go index 706d589..47da917 100644 --- a/supervisor.go +++ b/supervisor.go @@ -8,6 +8,7 @@ import ( "time" "github.com/Sirupsen/logrus" + "github.com/docker/containerd/linux" "github.com/docker/containerd/runtime" "github.com/opencontainers/runc/libcontainer" ) @@ -18,7 +19,7 @@ func NewSupervisor(stateDir string, concurrency int) (*Supervisor, error) { return nil, err } // register counters - r, err := NewRuntime(stateDir) + r, err := linux.NewRuntime(stateDir) if err != nil { return nil, err }