summaryrefslogtreecommitdiffhomepage
path: root/pkg/shim/v1/proc
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/shim/v1/proc')
-rw-r--r--pkg/shim/v1/proc/BUILD35
-rw-r--r--pkg/shim/v1/proc/deleted_state.go12
-rw-r--r--pkg/shim/v1/proc/exec.go25
-rw-r--r--pkg/shim/v1/proc/exec_state.go16
-rw-r--r--pkg/shim/v1/proc/init.go80
-rw-r--r--pkg/shim/v1/proc/init_state.go18
-rw-r--r--pkg/shim/v1/proc/io.go5
-rw-r--r--pkg/shim/v1/proc/process.go6
-rw-r--r--pkg/shim/v1/proc/types.go10
-rw-r--r--pkg/shim/v1/proc/utils.go2
10 files changed, 122 insertions, 87 deletions
diff --git a/pkg/shim/v1/proc/BUILD b/pkg/shim/v1/proc/BUILD
new file mode 100644
index 000000000..a59bf198d
--- /dev/null
+++ b/pkg/shim/v1/proc/BUILD
@@ -0,0 +1,35 @@
+load("//tools:defs.bzl", "go_library")
+
+package(licenses = ["notice"])
+
+go_library(
+ name = "proc",
+ srcs = [
+ "deleted_state.go",
+ "exec.go",
+ "exec_state.go",
+ "init.go",
+ "init_state.go",
+ "io.go",
+ "process.go",
+ "types.go",
+ "utils.go",
+ ],
+ visibility = [
+ "//pkg/shim:__subpackages__",
+ "//shim:__subpackages__",
+ ],
+ deps = [
+ "//pkg/shim/runsc",
+ "@com_github_containerd_console//:go_default_library",
+ "@com_github_containerd_containerd//errdefs:go_default_library",
+ "@com_github_containerd_containerd//log:go_default_library",
+ "@com_github_containerd_containerd//mount:go_default_library",
+ "@com_github_containerd_containerd//runtime/proc:go_default_library",
+ "@com_github_containerd_fifo//:go_default_library",
+ "@com_github_containerd_go_runc//:go_default_library",
+ "@com_github_gogo_protobuf//types:go_default_library",
+ "@com_github_opencontainers_runtime-spec//specs-go:go_default_library",
+ "@org_golang_x_sys//unix:go_default_library",
+ ],
+)
diff --git a/pkg/shim/v1/proc/deleted_state.go b/pkg/shim/v1/proc/deleted_state.go
index 0196c96dd..52aad40ac 100644
--- a/pkg/shim/v1/proc/deleted_state.go
+++ b/pkg/shim/v1/proc/deleted_state.go
@@ -17,33 +17,33 @@ package proc
import (
"context"
+ "fmt"
"github.com/containerd/console"
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/runtime/proc"
- "github.com/pkg/errors"
)
type deletedState struct{}
func (*deletedState) Resize(ws console.WinSize) error {
- return errors.Errorf("cannot resize a deleted process")
+ return fmt.Errorf("cannot resize a deleted process")
}
func (*deletedState) Start(ctx context.Context) error {
- return errors.Errorf("cannot start a deleted process")
+ return fmt.Errorf("cannot start a deleted process")
}
func (*deletedState) Delete(ctx context.Context) error {
- return errors.Wrap(errdefs.ErrNotFound, "cannot delete a deleted process")
+ return fmt.Errorf("cannot delete a deleted process: %w", errdefs.ErrNotFound)
}
func (*deletedState) Kill(ctx context.Context, sig uint32, all bool) error {
- return errors.Wrap(errdefs.ErrNotFound, "cannot kill a deleted process")
+ return fmt.Errorf("cannot kill a deleted process: %w", errdefs.ErrNotFound)
}
func (*deletedState) SetExited(status int) {}
func (*deletedState) Exec(ctx context.Context, path string, r *ExecConfig) (proc.Process, error) {
- return nil, errors.Errorf("cannot exec in a deleted state")
+ return nil, fmt.Errorf("cannot exec in a deleted state")
}
diff --git a/pkg/shim/v1/proc/exec.go b/pkg/shim/v1/proc/exec.go
index 6821e09cd..4ef9cf6cf 100644
--- a/pkg/shim/v1/proc/exec.go
+++ b/pkg/shim/v1/proc/exec.go
@@ -31,7 +31,6 @@ import (
"github.com/containerd/fifo"
runc "github.com/containerd/go-runc"
specs "github.com/opencontainers/runtime-spec/specs-go"
- "github.com/pkg/errors"
"golang.org/x/sys/unix"
"gvisor.dev/gvisor/pkg/shim/runsc"
@@ -151,9 +150,11 @@ func (e *execProcess) kill(ctx context.Context, sig uint32, _ bool) error {
if err := e.parent.runtime.Kill(ctx, e.parent.id, int(sig), &runsc.KillOpts{
Pid: internalPid,
}); err != nil {
- // If this returns error, consider the process has already stopped.
+ // If this returns error, consider the process has
+ // already stopped.
+ //
// TODO: Fix after signal handling is fixed.
- return errors.Wrapf(errdefs.ErrNotFound, err.Error())
+ return fmt.Errorf("%s: %w", err.Error(), errdefs.ErrNotFound)
}
}
return nil
@@ -182,16 +183,16 @@ func (e *execProcess) start(ctx context.Context) (err error) {
)
if e.stdio.Terminal {
if socket, err = runc.NewTempConsoleSocket(); err != nil {
- return errors.Wrap(err, "failed to create runc console socket")
+ return fmt.Errorf("failed to create runc console socket: %w", err)
}
defer socket.Close()
} else if e.stdio.IsNull() {
if e.io, err = runc.NewNullIO(); err != nil {
- return errors.Wrap(err, "creating new NULL IO")
+ return fmt.Errorf("creating new NULL IO: %w", err)
}
} else {
if e.io, err = runc.NewPipeIO(e.parent.IoUID, e.parent.IoGID, withConditionalIO(e.stdio)); err != nil {
- return errors.Wrap(err, "failed to create runc io pipes")
+ return fmt.Errorf("failed to create runc io pipes: %w", err)
}
}
opts := &runsc.ExecOpts{
@@ -217,7 +218,7 @@ func (e *execProcess) start(ctx context.Context) (err error) {
if e.stdio.Stdin != "" {
sc, err := fifo.OpenFifo(context.Background(), e.stdio.Stdin, syscall.O_WRONLY|syscall.O_NONBLOCK, 0)
if err != nil {
- return errors.Wrapf(err, "failed to open stdin fifo %s", e.stdio.Stdin)
+ return fmt.Errorf("failed to open stdin fifo %s: %w", e.stdio.Stdin, err)
}
e.closers = append(e.closers, sc)
e.stdin = sc
@@ -228,25 +229,25 @@ func (e *execProcess) start(ctx context.Context) (err error) {
if socket != nil {
console, err := socket.ReceiveMaster()
if err != nil {
- return errors.Wrap(err, "failed to retrieve console master")
+ return fmt.Errorf("failed to retrieve console master: %w", err)
}
if e.console, err = e.parent.Platform.CopyConsole(ctx, console, e.stdio.Stdin, e.stdio.Stdout, e.stdio.Stderr, &e.wg, &copyWaitGroup); err != nil {
- return errors.Wrap(err, "failed to start console copy")
+ return fmt.Errorf("failed to start console copy: %w", err)
}
} else if !e.stdio.IsNull() {
if err := copyPipes(ctx, e.io, e.stdio.Stdin, e.stdio.Stdout, e.stdio.Stderr, &e.wg, &copyWaitGroup); err != nil {
- return errors.Wrap(err, "failed to start io pipe copy")
+ return fmt.Errorf("failed to start io pipe copy: %w", err)
}
}
copyWaitGroup.Wait()
pid, err := runc.ReadPidFile(opts.PidFile)
if err != nil {
- return errors.Wrap(err, "failed to retrieve OCI runtime exec pid")
+ return fmt.Errorf("failed to retrieve OCI runtime exec pid: %w", err)
}
e.pid = pid
internalPid, err := runc.ReadPidFile(opts.InternalPidFile)
if err != nil {
- return errors.Wrap(err, "failed to retrieve OCI runtime exec internal pid")
+ return fmt.Errorf("failed to retrieve OCI runtime exec internal pid: %w", err)
}
e.internalPid = internalPid
go func() {
diff --git a/pkg/shim/v1/proc/exec_state.go b/pkg/shim/v1/proc/exec_state.go
index 5416cb601..4dcda8b44 100644
--- a/pkg/shim/v1/proc/exec_state.go
+++ b/pkg/shim/v1/proc/exec_state.go
@@ -17,9 +17,9 @@ package proc
import (
"context"
+ "fmt"
"github.com/containerd/console"
- "github.com/pkg/errors"
)
type execState interface {
@@ -43,7 +43,7 @@ func (s *execCreatedState) transition(name string) error {
case "deleted":
s.p.execState = &deletedState{}
default:
- return errors.Errorf("invalid state transition %q to %q", stateName(s), name)
+ return fmt.Errorf("invalid state transition %q to %q", stateName(s), name)
}
return nil
}
@@ -87,7 +87,7 @@ func (s *execRunningState) transition(name string) error {
case "stopped":
s.p.execState = &execStoppedState{p: s.p}
default:
- return errors.Errorf("invalid state transition %q to %q", stateName(s), name)
+ return fmt.Errorf("invalid state transition %q to %q", stateName(s), name)
}
return nil
}
@@ -97,11 +97,11 @@ func (s *execRunningState) Resize(ws console.WinSize) error {
}
func (s *execRunningState) Start(ctx context.Context) error {
- return errors.Errorf("cannot start a running process")
+ return fmt.Errorf("cannot start a running process")
}
func (s *execRunningState) Delete(ctx context.Context) error {
- return errors.Errorf("cannot delete a running process")
+ return fmt.Errorf("cannot delete a running process")
}
func (s *execRunningState) Kill(ctx context.Context, sig uint32, all bool) error {
@@ -125,17 +125,17 @@ func (s *execStoppedState) transition(name string) error {
case "deleted":
s.p.execState = &deletedState{}
default:
- return errors.Errorf("invalid state transition %q to %q", stateName(s), name)
+ return fmt.Errorf("invalid state transition %q to %q", stateName(s), name)
}
return nil
}
func (s *execStoppedState) Resize(ws console.WinSize) error {
- return errors.Errorf("cannot resize a stopped container")
+ return fmt.Errorf("cannot resize a stopped container")
}
func (s *execStoppedState) Start(ctx context.Context) error {
- return errors.Errorf("cannot start a stopped process")
+ return fmt.Errorf("cannot start a stopped process")
}
func (s *execStoppedState) Delete(ctx context.Context) error {
diff --git a/pkg/shim/v1/proc/init.go b/pkg/shim/v1/proc/init.go
index 0771540a9..b429cb94f 100644
--- a/pkg/shim/v1/proc/init.go
+++ b/pkg/shim/v1/proc/init.go
@@ -18,6 +18,7 @@ package proc
import (
"context"
"encoding/json"
+ "fmt"
"io"
"path/filepath"
"strings"
@@ -33,23 +34,22 @@ import (
"github.com/containerd/fifo"
runc "github.com/containerd/go-runc"
specs "github.com/opencontainers/runtime-spec/specs-go"
- "github.com/pkg/errors"
"gvisor.dev/gvisor/pkg/shim/runsc"
)
-// InitPidFile name of the file that contains the init pid
+// InitPidFile name of the file that contains the init pid.
const InitPidFile = "init.pid"
-// Init represents an initial process for a container
+// Init represents an initial process for a container.
type Init struct {
wg sync.WaitGroup
initState initState
// mu is used to ensure that `Start()` and `Exited()` calls return in
- // the right order when invoked in separate go routines.
- // This is the case within the shim implementation as it makes use of
- // the reaper interface.
+ // the right order when invoked in separate go routines. This is the
+ // case within the shim implementation as it makes use of the reaper
+ // interface.
mu sync.Mutex
waitBlock chan struct{}
@@ -76,7 +76,7 @@ type Init struct {
Monitor ProcessMonitor
}
-// NewRunsc returns a new runsc instance for a process
+// NewRunsc returns a new runsc instance for a process.
func NewRunsc(root, path, namespace, runtime string, config map[string]string) *runsc.Runsc {
if root == "" {
root = RunscRoot
@@ -91,7 +91,7 @@ func NewRunsc(root, path, namespace, runtime string, config map[string]string) *
}
}
-// New returns a new init process
+// New returns a new init process.
func New(id string, runtime *runsc.Runsc, stdio proc.Stdio) *Init {
p := &Init{
id: id,
@@ -104,21 +104,21 @@ func New(id string, runtime *runsc.Runsc, stdio proc.Stdio) *Init {
return p
}
-// Create the process with the provided config
+// Create the process with the provided config.
func (p *Init) Create(ctx context.Context, r *CreateConfig) (err error) {
var socket *runc.Socket
if r.Terminal {
if socket, err = runc.NewTempConsoleSocket(); err != nil {
- return errors.Wrap(err, "failed to create OCI runtime console socket")
+ return fmt.Errorf("failed to create OCI runtime console socket: %w", err)
}
defer socket.Close()
} else if hasNoIO(r) {
if p.io, err = runc.NewNullIO(); err != nil {
- return errors.Wrap(err, "creating new NULL IO")
+ return fmt.Errorf("creating new NULL IO: %w", err)
}
} else {
if p.io, err = runc.NewPipeIO(p.IoUID, p.IoGID, withConditionalIO(p.stdio)); err != nil {
- return errors.Wrap(err, "failed to create OCI runtime io pipes")
+ return fmt.Errorf("failed to create OCI runtime io pipes: %w", err)
}
}
pidFile := filepath.Join(p.Bundle, InitPidFile)
@@ -139,7 +139,7 @@ func (p *Init) Create(ctx context.Context, r *CreateConfig) (err error) {
if r.Stdin != "" {
sc, err := fifo.OpenFifo(context.Background(), r.Stdin, syscall.O_WRONLY|syscall.O_NONBLOCK, 0)
if err != nil {
- return errors.Wrapf(err, "failed to open stdin fifo %s", r.Stdin)
+ return fmt.Errorf("failed to open stdin fifo %s: %w", r.Stdin, err)
}
p.stdin = sc
p.closers = append(p.closers, sc)
@@ -150,58 +150,58 @@ func (p *Init) Create(ctx context.Context, r *CreateConfig) (err error) {
if socket != nil {
console, err := socket.ReceiveMaster()
if err != nil {
- return errors.Wrap(err, "failed to retrieve console master")
+ return fmt.Errorf("failed to retrieve console master: %w", err)
}
console, err = p.Platform.CopyConsole(ctx, console, r.Stdin, r.Stdout, r.Stderr, &p.wg, &copyWaitGroup)
if err != nil {
- return errors.Wrap(err, "failed to start console copy")
+ return fmt.Errorf("failed to start console copy: %w", err)
}
p.console = console
} else if !hasNoIO(r) {
if err := copyPipes(ctx, p.io, r.Stdin, r.Stdout, r.Stderr, &p.wg, &copyWaitGroup); err != nil {
- return errors.Wrap(err, "failed to start io pipe copy")
+ return fmt.Errorf("failed to start io pipe copy: %w", err)
}
}
copyWaitGroup.Wait()
pid, err := runc.ReadPidFile(pidFile)
if err != nil {
- return errors.Wrap(err, "failed to retrieve OCI runtime container pid")
+ return fmt.Errorf("failed to retrieve OCI runtime container pid: %w", err)
}
p.pid = pid
return nil
}
-// Wait for the process to exit
+// Wait waits for the process to exit.
func (p *Init) Wait() {
<-p.waitBlock
}
-// ID of the process
+// ID returns the ID of the process.
func (p *Init) ID() string {
return p.id
}
-// Pid of the process
+// Pid returns the PID of the process.
func (p *Init) Pid() int {
return p.pid
}
-// ExitStatus of the process
+// ExitStatus returns the exit status of the process.
func (p *Init) ExitStatus() int {
p.mu.Lock()
defer p.mu.Unlock()
return p.status
}
-// ExitedAt at time when the process exited
+// ExitedAt returns the time when the process exited.
func (p *Init) ExitedAt() time.Time {
p.mu.Lock()
defer p.mu.Unlock()
return p.exited
}
-// Status of the process
+// Status returns the status of the process.
func (p *Init) Status(ctx context.Context) (string, error) {
p.mu.Lock()
defer p.mu.Unlock()
@@ -215,7 +215,7 @@ func (p *Init) Status(ctx context.Context) (string, error) {
return p.convertStatus(c.Status), nil
}
-// Start the init process
+// Start starts the init process.
func (p *Init) Start(ctx context.Context) error {
p.mu.Lock()
defer p.mu.Unlock()
@@ -250,7 +250,7 @@ func (p *Init) start(ctx context.Context) error {
return nil
}
-// SetExited of the init process with the next status
+// SetExited set the exit stauts of the init process.
func (p *Init) SetExited(status int) {
p.mu.Lock()
defer p.mu.Unlock()
@@ -265,7 +265,7 @@ func (p *Init) setExited(status int) {
close(p.waitBlock)
}
-// Delete the init process
+// Delete deletes the init process.
func (p *Init) Delete(ctx context.Context) error {
p.mu.Lock()
defer p.mu.Unlock()
@@ -298,13 +298,13 @@ func (p *Init) delete(ctx context.Context) error {
if err2 := mount.UnmountAll(p.Rootfs, 0); err2 != nil {
log.G(ctx).WithError(err2).Warn("failed to cleanup rootfs mount")
if err == nil {
- err = errors.Wrap(err2, "failed rootfs umount")
+ err = fmt.Errorf("failed rootfs umount: %w", err2)
}
}
return err
}
-// Resize the init processes console
+// Resize resizes the init processes console.
func (p *Init) Resize(ws console.WinSize) error {
p.mu.Lock()
defer p.mu.Unlock()
@@ -322,7 +322,7 @@ func (p *Init) resize(ws console.WinSize) error {
return p.console.Resize(ws)
}
-// Kill the init process
+// Kill kills the init process.
func (p *Init) Kill(ctx context.Context, signal uint32, all bool) error {
p.mu.Lock()
defer p.mu.Unlock()
@@ -340,7 +340,7 @@ func (p *Init) kill(context context.Context, signal uint32, all bool) error {
c, err := p.runtime.State(context, p.id)
if err != nil {
if strings.Contains(err.Error(), "does not exist") {
- return errors.Wrapf(errdefs.ErrNotFound, "no such process")
+ return fmt.Errorf("no such process: %w", errdefs.ErrNotFound)
}
return p.runtimeError(err, "OCI runtime state failed")
}
@@ -348,7 +348,7 @@ func (p *Init) kill(context context.Context, signal uint32, all bool) error {
// If the container is not in running state, directly return
// "no such process"
if p.convertStatus(c.Status) == "stopped" {
- return errors.Wrapf(errdefs.ErrNotFound, "no such process")
+ return fmt.Errorf("no such process: %w", errdefs.ErrNotFound)
}
killErr = p.runtime.Kill(context, p.id, int(signal), &runsc.KillOpts{
All: all,
@@ -362,7 +362,7 @@ func (p *Init) kill(context context.Context, signal uint32, all bool) error {
return p.runtimeError(killErr, "kill timeout")
}
-// KillAll processes belonging to the init process
+// KillAll kills all processes belonging to the init process.
func (p *Init) KillAll(context context.Context) error {
p.mu.Lock()
defer p.mu.Unlock()
@@ -380,17 +380,17 @@ func (p *Init) killAll(context context.Context) error {
return nil
}
-// Stdin of the process
+// Stdin returns the stdin of the process.
func (p *Init) Stdin() io.Closer {
return p.stdin
}
-// Runtime returns the OCI runtime configured for the init process
+// Runtime returns the OCI runtime configured for the init process.
func (p *Init) Runtime() *runsc.Runsc {
return p.runtime
}
-// Exec returns a new child process
+// Exec returns a new child process.
func (p *Init) Exec(ctx context.Context, path string, r *ExecConfig) (proc.Process, error) {
p.mu.Lock()
defer p.mu.Unlock()
@@ -398,7 +398,7 @@ func (p *Init) Exec(ctx context.Context, path string, r *ExecConfig) (proc.Proce
return p.initState.Exec(ctx, path, r)
}
-// exec returns a new exec'd process
+// exec returns a new exec'd process.
func (p *Init) exec(ctx context.Context, path string, r *ExecConfig) (proc.Process, error) {
// process exec request
var spec specs.Process
@@ -424,7 +424,7 @@ func (p *Init) exec(ctx context.Context, path string, r *ExecConfig) (proc.Proce
return e, nil
}
-// Stdio of the process
+// Stdio returns the stdio of the process.
func (p *Init) Stdio() proc.Stdio {
return p.stdio
}
@@ -437,11 +437,11 @@ func (p *Init) runtimeError(rErr error, msg string) error {
rMsg, err := getLastRuntimeError(p.runtime)
switch {
case err != nil:
- return errors.Wrapf(rErr, "%s: %s (%s)", msg, "unable to retrieve OCI runtime error", err.Error())
+ return fmt.Errorf("%s: %w (unable to retrieve OCI runtime error: %v)", msg, rErr, err)
case rMsg == "":
- return errors.Wrap(rErr, msg)
+ return fmt.Errorf("%s: %w", msg, rErr)
default:
- return errors.Errorf("%s: %s", msg, rMsg)
+ return fmt.Errorf("%s: %s", msg, rMsg)
}
}
diff --git a/pkg/shim/v1/proc/init_state.go b/pkg/shim/v1/proc/init_state.go
index 868646b6c..509f27762 100644
--- a/pkg/shim/v1/proc/init_state.go
+++ b/pkg/shim/v1/proc/init_state.go
@@ -17,11 +17,11 @@ package proc
import (
"context"
+ "fmt"
"github.com/containerd/console"
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/runtime/proc"
- "github.com/pkg/errors"
)
type initState interface {
@@ -46,7 +46,7 @@ func (s *createdState) transition(name string) error {
case "deleted":
s.p.initState = &deletedState{}
default:
- return errors.Errorf("invalid state transition %q to %q", stateName(s), name)
+ return fmt.Errorf("invalid state transition %q to %q", stateName(s), name)
}
return nil
}
@@ -107,7 +107,7 @@ func (s *runningState) transition(name string) error {
case "stopped":
s.p.initState = &stoppedState{p: s.p}
default:
- return errors.Errorf("invalid state transition %q to %q", stateName(s), name)
+ return fmt.Errorf("invalid state transition %q to %q", stateName(s), name)
}
return nil
}
@@ -117,11 +117,11 @@ func (s *runningState) Resize(ws console.WinSize) error {
}
func (s *runningState) Start(ctx context.Context) error {
- return errors.Errorf("cannot start a running process")
+ return fmt.Errorf("cannot start a running process")
}
func (s *runningState) Delete(ctx context.Context) error {
- return errors.Errorf("cannot delete a running process")
+ return fmt.Errorf("cannot delete a running process")
}
func (s *runningState) Kill(ctx context.Context, sig uint32, all bool) error {
@@ -149,17 +149,17 @@ func (s *stoppedState) transition(name string) error {
case "deleted":
s.p.initState = &deletedState{}
default:
- return errors.Errorf("invalid state transition %q to %q", stateName(s), name)
+ return fmt.Errorf("invalid state transition %q to %q", stateName(s), name)
}
return nil
}
func (s *stoppedState) Resize(ws console.WinSize) error {
- return errors.Errorf("cannot resize a stopped container")
+ return fmt.Errorf("cannot resize a stopped container")
}
func (s *stoppedState) Start(ctx context.Context) error {
- return errors.Errorf("cannot start a stopped process")
+ return fmt.Errorf("cannot start a stopped process")
}
func (s *stoppedState) Delete(ctx context.Context) error {
@@ -178,5 +178,5 @@ func (s *stoppedState) SetExited(status int) {
}
func (s *stoppedState) Exec(ctx context.Context, path string, r *ExecConfig) (proc.Process, error) {
- return nil, errors.Errorf("cannot exec in a stopped state")
+ return nil, fmt.Errorf("cannot exec in a stopped state")
}
diff --git a/pkg/shim/v1/proc/io.go b/pkg/shim/v1/proc/io.go
index 2677b4e54..5313c7a50 100644
--- a/pkg/shim/v1/proc/io.go
+++ b/pkg/shim/v1/proc/io.go
@@ -150,8 +150,9 @@ func (c *countingWriteCloser) Close() error {
return c.WriteCloser.Close()
}
-// isFifo checks if a file is a fifo
-// if the file does not exist then it returns false
+// isFifo checks if a file is a fifo.
+//
+// If the file does not exist then it returns false.
func isFifo(path string) (bool, error) {
stat, err := os.Stat(path)
if err != nil {
diff --git a/pkg/shim/v1/proc/process.go b/pkg/shim/v1/proc/process.go
index 1bfa99f4c..d462c3eef 100644
--- a/pkg/shim/v1/proc/process.go
+++ b/pkg/shim/v1/proc/process.go
@@ -16,10 +16,10 @@
package proc
import (
- "github.com/pkg/errors"
+ "fmt"
)
-// RunscRoot is the path to the root runsc state directory
+// RunscRoot is the path to the root runsc state directory.
const RunscRoot = "/run/containerd/runsc"
func stateName(v interface{}) string {
@@ -33,5 +33,5 @@ func stateName(v interface{}) string {
case *stoppedState:
return "stopped"
}
- panic(errors.Errorf("invalid state %v", v))
+ panic(fmt.Errorf("invalid state %v", v))
}
diff --git a/pkg/shim/v1/proc/types.go b/pkg/shim/v1/proc/types.go
index dcd43bcca..5c215de5f 100644
--- a/pkg/shim/v1/proc/types.go
+++ b/pkg/shim/v1/proc/types.go
@@ -23,7 +23,7 @@ import (
runc "github.com/containerd/go-runc"
)
-// Mount holds filesystem mount configuration
+// Mount holds filesystem mount configuration.
type Mount struct {
Type string
Source string
@@ -31,7 +31,7 @@ type Mount struct {
Options []string
}
-// CreateConfig hold task creation configuration
+// CreateConfig hold task creation configuration.
type CreateConfig struct {
ID string
Bundle string
@@ -44,7 +44,7 @@ type CreateConfig struct {
Options *google_protobuf.Any
}
-// ExecConfig holds exec creation configuration
+// ExecConfig holds exec creation configuration.
type ExecConfig struct {
ID string
Terminal bool
@@ -54,14 +54,14 @@ type ExecConfig struct {
Spec *google_protobuf.Any
}
-// Exit is the type of exit events
+// Exit is the type of exit events.
type Exit struct {
Timestamp time.Time
ID string
Status int
}
-// ProcessMonitor monitors process exit changes
+// ProcessMonitor monitors process exit changes.
type ProcessMonitor interface {
// Subscribe to process exit changes
Subscribe() chan runc.Exit
diff --git a/pkg/shim/v1/proc/utils.go b/pkg/shim/v1/proc/utils.go
index 6e7dbdad7..716de2f59 100644
--- a/pkg/shim/v1/proc/utils.go
+++ b/pkg/shim/v1/proc/utils.go
@@ -34,8 +34,6 @@ const (
// inside the sandbox.
var ExitCh = make(chan Exit, bufferSize)
-// TODO(random-liu): This can be a utility.
-
// TODO(mlaventure): move to runc package?
func getLastRuntimeError(r *runsc.Runsc) (string, error) {
if r.Log == "" {