diff options
author | Fabricio Voznika <fvoznika@google.com> | 2019-01-18 17:35:09 -0800 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2019-01-18 17:36:02 -0800 |
commit | c1be25b78d89a3a55a32a7aa10724134eda9813d (patch) | |
tree | bb5c09cb94ab212c158041b260ed0bb480e2a9d5 /runsc | |
parent | c0a981629cf44688687548490c5e665d851afe06 (diff) |
Scrub runsc error messages
Removed "error" and "failed to" prefix that don't add value
from messages. Adjusted a few other messages. In particular,
when the container fail to start, the message returned is easier
for humans to read:
$ docker run --rm --runtime=runsc alpine foobar
docker: Error response from daemon: OCI runtime start failed: <path> did not terminate sucessfully: starting container: starting root container [foobar]: starting sandbox: searching for executable "foobar", cwd: "/", $PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin": no such file or directory
Closes #77
PiperOrigin-RevId: 230022798
Change-Id: I83339017c70dae09e4f9f8e0ea2e554c4d5d5cd1
Diffstat (limited to 'runsc')
-rw-r--r-- | runsc/boot/controller.go | 12 | ||||
-rw-r--r-- | runsc/boot/fs.go | 43 | ||||
-rw-r--r-- | runsc/boot/loader.go | 81 | ||||
-rw-r--r-- | runsc/cgroup/cgroup.go | 2 | ||||
-rw-r--r-- | runsc/cmd/boot.go | 8 | ||||
-rw-r--r-- | runsc/cmd/checkpoint.go | 14 | ||||
-rw-r--r-- | runsc/cmd/create.go | 4 | ||||
-rw-r--r-- | runsc/cmd/debug.go | 8 | ||||
-rw-r--r-- | runsc/cmd/delete.go | 4 | ||||
-rw-r--r-- | runsc/cmd/events.go | 6 | ||||
-rw-r--r-- | runsc/cmd/exec.go | 24 | ||||
-rw-r--r-- | runsc/cmd/gofer.go | 16 | ||||
-rw-r--r-- | runsc/cmd/kill.go | 2 | ||||
-rw-r--r-- | runsc/cmd/list.go | 4 | ||||
-rw-r--r-- | runsc/cmd/path.go | 2 | ||||
-rw-r--r-- | runsc/cmd/pause.go | 2 | ||||
-rw-r--r-- | runsc/cmd/ps.go | 8 | ||||
-rw-r--r-- | runsc/cmd/restore.go | 8 | ||||
-rw-r--r-- | runsc/cmd/resume.go | 2 | ||||
-rw-r--r-- | runsc/cmd/run.go | 4 | ||||
-rw-r--r-- | runsc/cmd/spec.go | 2 | ||||
-rw-r--r-- | runsc/cmd/start.go | 4 | ||||
-rw-r--r-- | runsc/cmd/state.go | 4 | ||||
-rw-r--r-- | runsc/cmd/wait.go | 12 | ||||
-rw-r--r-- | runsc/console/console.go | 8 | ||||
-rw-r--r-- | runsc/container/container.go | 34 | ||||
-rw-r--r-- | runsc/container/fs.go | 6 | ||||
-rw-r--r-- | runsc/sandbox/network.go | 26 | ||||
-rw-r--r-- | runsc/sandbox/sandbox.go | 62 |
29 files changed, 211 insertions, 201 deletions
diff --git a/runsc/boot/controller.go b/runsc/boot/controller.go index 36e9d2c6b..989f49388 100644 --- a/runsc/boot/controller.go +++ b/runsc/boot/controller.go @@ -163,7 +163,7 @@ func (cm *containerManager) StartRoot(cid *string, _ *struct{}) error { // Tell the root container to start and wait for the result. cm.startChan <- struct{}{} if err := <-cm.startResultChan; err != nil { - return fmt.Errorf("failed to start sandbox: %v", err) + return fmt.Errorf("starting sandbox: %v", err) } return nil } @@ -319,7 +319,7 @@ func (cm *containerManager) Restore(o *RestoreOpts, _ *struct{}) error { p, err := createPlatform(cm.l.conf, int(deviceFile.Fd())) if err != nil { - return fmt.Errorf("error creating platform: %v", err) + return fmt.Errorf("creating platform: %v", err) } k := &kernel.Kernel{ Platform: p, @@ -330,14 +330,14 @@ func (cm *containerManager) Restore(o *RestoreOpts, _ *struct{}) error { fds := &fdDispenser{fds: cm.l.goferFDs} renv, err := createRestoreEnvironment(cm.l.spec, cm.l.conf, fds) if err != nil { - return fmt.Errorf("error creating RestoreEnvironment: %v", err) + return fmt.Errorf("creating RestoreEnvironment: %v", err) } fs.SetRestoreEnvironment(*renv) // Prepare to load from the state file. networkStack, err := newEmptyNetworkStack(cm.l.conf, k) if err != nil { - return fmt.Errorf("failed to create network: %v", err) + return fmt.Errorf("creating network: %v", err) } if eps, ok := networkStack.(*epsocket.Stack); ok { stack.StackFromEnv = eps.Stack // FIXME @@ -347,7 +347,7 @@ func (cm *containerManager) Restore(o *RestoreOpts, _ *struct{}) error { return err } if info.Size() == 0 { - return fmt.Errorf("error file was empty") + return fmt.Errorf("file cannot be empty") } // Load the state. @@ -385,7 +385,7 @@ func (cm *containerManager) Restore(o *RestoreOpts, _ *struct{}) error { // Tell the root container to start and wait for the result. cm.startChan <- struct{}{} if err := <-cm.startResultChan; err != nil { - return fmt.Errorf("failed to start sandbox: %v", err) + return fmt.Errorf("starting sandbox: %v", err) } return nil diff --git a/runsc/boot/fs.go b/runsc/boot/fs.go index e0c8291ac..5c5e650ca 100644 --- a/runsc/boot/fs.go +++ b/runsc/boot/fs.go @@ -98,11 +98,11 @@ func setupRootContainerFS(userCtx context.Context, rootCtx context.Context, spec fds := &fdDispenser{fds: goferFDs} rootInode, err := createRootMount(rootCtx, spec, conf, fds, mounts) if err != nil { - return fmt.Errorf("failed to create root mount: %v", err) + return fmt.Errorf("creating root mount: %v", err) } mns, err := fs.NewMountNamespace(userCtx, rootInode) if err != nil { - return fmt.Errorf("failed to create root mount namespace: %v", err) + return fmt.Errorf("creating root mount namespace: %v", err) } setMountNS(mns) @@ -183,7 +183,7 @@ func createRootMount(ctx context.Context, spec *specs.Spec, conf *Config, fds *f opts := p9MountOptions(fd, conf.FileAccess) rootInode, err = p9FS.Mount(ctx, rootDevice, mf, strings.Join(opts, ",")) if err != nil { - return nil, fmt.Errorf("failed to generate root mount point: %v", err) + return nil, fmt.Errorf("creating root mount point: %v", err) } // We need to overlay the root on top of a ramfs with stub directories @@ -192,7 +192,7 @@ func createRootMount(ctx context.Context, spec *specs.Spec, conf *Config, fds *f submounts := append(subtargets("/", mounts), "/dev", "/sys", "/proc", "/tmp") rootInode, err = addSubmountOverlay(ctx, rootInode, submounts) if err != nil { - return nil, fmt.Errorf("error adding submount overlay: %v", err) + return nil, fmt.Errorf("adding submount overlay: %v", err) } if conf.Overlay && !spec.Root.Readonly { @@ -204,7 +204,7 @@ func createRootMount(ctx context.Context, spec *specs.Spec, conf *Config, fds *f } } - log.Infof("Mounted %q to \"/\" type root", spec.Root.Path) + log.Infof("Mounted %q to %q type root", spec.Root.Path, "/") return rootInode, nil } @@ -222,7 +222,7 @@ func addOverlay(ctx context.Context, conf *Config, lower *fs.Inode, name string, // Create overlay on top of mount dir. upper, err := tmpFS.Mount(ctx, name+"-upper", lowerFlags, "") if err != nil { - return nil, fmt.Errorf("failed to create tmpfs overlay: %v", err) + return nil, fmt.Errorf("creating tmpfs overlay: %v", err) } return fs.NewOverlayRoot(ctx, upper, lower, lowerFlags) } @@ -311,7 +311,7 @@ func mountSubmount(ctx context.Context, conf *Config, mns *fs.MountNamespace, ro inode, err := filesystem.Mount(ctx, mountDevice(m), mf, strings.Join(opts, ",")) if err != nil { - return fmt.Errorf("failed to create mount with source %q: %v", m.Source, err) + return fmt.Errorf("creating mount with source %q: %v", m.Source, err) } // If there are submounts, we need to overlay the mount on top of a @@ -321,7 +321,7 @@ func mountSubmount(ctx context.Context, conf *Config, mns *fs.MountNamespace, ro log.Infof("Adding submount overlay over %q", m.Destination) inode, err = addSubmountOverlay(ctx, inode, submounts) if err != nil { - return fmt.Errorf("error adding submount overlay: %v", err) + return fmt.Errorf("adding submount overlay: %v", err) } } @@ -336,11 +336,11 @@ func mountSubmount(ctx context.Context, conf *Config, mns *fs.MountNamespace, ro maxTraversals := uint(0) dirent, err := mns.FindInode(ctx, root, root, m.Destination, &maxTraversals) if err != nil { - return fmt.Errorf("failed to find mount destination %q: %v", m.Destination, err) + return fmt.Errorf("can't find mount destination %q: %v", m.Destination, err) } defer dirent.DecRef() if err := mns.Mount(ctx, dirent, inode); err != nil { - return fmt.Errorf("failed to mount at destination %q: %v", m.Destination, err) + return fmt.Errorf("mount %q error: %v", m.Destination, err) } log.Infof("Mounted %q to %q type %s", m.Source, m.Destination, m.Type) @@ -503,11 +503,11 @@ func addSubmountOverlay(ctx context.Context, inode *fs.Inode, submounts []string msrc := fs.NewPseudoMountSource() mountTree, err := ramfs.MakeDirectoryTree(ctx, msrc, submounts) if err != nil { - return nil, fmt.Errorf("error creating mount tree: %v", err) + return nil, fmt.Errorf("creating mount tree: %v", err) } overlayInode, err := fs.NewOverlayRoot(ctx, inode, mountTree, fs.MountSourceFlags{}) if err != nil { - return nil, fmt.Errorf("failed to make mount overlay: %v", err) + return nil, fmt.Errorf("adding mount overlay: %v", err) } return overlayInode, err } @@ -544,7 +544,7 @@ func setupContainerFS(procArgs *kernel.CreateProcessArgs, spec *specs.Spec, conf // fd. fdm, err := createFDMap(ctx, k, ls, console, stdioFDs) if err != nil { - return fmt.Errorf("error importing fds: %v", err) + return fmt.Errorf("importing fds: %v", err) } // CreateProcess takes a reference on FDMap if successful. We @@ -595,7 +595,7 @@ func setupContainerFS(procArgs *kernel.CreateProcessArgs, spec *specs.Spec, conf fds := &fdDispenser{fds: goferFDs} rootInode, err := createRootMount(rootCtx, spec, conf, fds, nil) if err != nil { - return fmt.Errorf("error creating filesystem for container: %v", err) + return fmt.Errorf("creating filesystem for container: %v", err) } // Mount the container's root filesystem to the newly created mount point. @@ -630,9 +630,10 @@ func setupContainerFS(procArgs *kernel.CreateProcessArgs, spec *specs.Spec, conf // executable matching the procArgs.Argv[0]. func setExecutablePath(ctx context.Context, mns *fs.MountNamespace, procArgs *kernel.CreateProcessArgs) error { paths := fs.GetPath(procArgs.Envv) - f, err := mns.ResolveExecutablePath(ctx, procArgs.WorkingDirectory, procArgs.Argv[0], paths) + exe := procArgs.Argv[0] + f, err := mns.ResolveExecutablePath(ctx, procArgs.WorkingDirectory, exe, paths) if err != nil { - return err + return fmt.Errorf("searching for executable %q, cwd: %q, $PATH=%q: %v", exe, procArgs.WorkingDirectory, strings.Join(paths, ":"), err) } procArgs.Filename = f return nil @@ -666,7 +667,7 @@ func destroyContainerFS(ctx context.Context, cid string, k *kernel.Kernel) error return nil } if err != nil { - return fmt.Errorf("error finding container root directory %q: %v", containerRoot, err) + return fmt.Errorf("finding container root directory %q: %v", containerRoot, err) } defer containerRootDirent.DecRef() @@ -682,7 +683,7 @@ func destroyContainerFS(ctx context.Context, cid string, k *kernel.Kernel) error log.Debugf("Unmounting container submount %q", root.BaseName()) m.FlushDirentRefs() if err := mns.Unmount(ctx, root, true /* detach only */); err != nil && err != syserror.EINVAL { - return fmt.Errorf("error unmounting container submount %q: %v", root.BaseName(), err) + return fmt.Errorf("unmounting container submount %q: %v", root.BaseName(), err) } } @@ -690,7 +691,7 @@ func destroyContainerFS(ctx context.Context, cid string, k *kernel.Kernel) error log.Debugf("Unmounting container root %q", containerRoot) containerRootDirent.Inode.MountSource.FlushDirentRefs() if err := mns.Unmount(ctx, containerRootDirent, true /* detach only */); err != nil { - return fmt.Errorf("error unmounting container root mount %q: %v", containerRootDirent.BaseName(), err) + return fmt.Errorf("unmounting container root mount %q: %v", containerRootDirent.BaseName(), err) } // Get a reference to the parent directory and remove the root @@ -698,12 +699,12 @@ func destroyContainerFS(ctx context.Context, cid string, k *kernel.Kernel) error maxTraversals = 0 containersDirDirent, err := mns.FindInode(ctx, mnsRoot, nil, ChildContainersDir, &maxTraversals) if err != nil { - return fmt.Errorf("error finding containers directory %q: %v", ChildContainersDir, err) + return fmt.Errorf("finding containers directory %q: %v", ChildContainersDir, err) } defer containersDirDirent.DecRef() log.Debugf("Deleting container root %q", containerRoot) if err := containersDirDirent.RemoveDirectory(ctx, mnsRoot, cid); err != nil { - return fmt.Errorf("error removing directory %q: %v", containerRoot, err) + return fmt.Errorf("removing directory %q: %v", containerRoot, err) } return nil diff --git a/runsc/boot/loader.go b/runsc/boot/loader.go index 71a2ab962..f3dc15f00 100644 --- a/runsc/boot/loader.go +++ b/runsc/boot/loader.go @@ -173,17 +173,17 @@ func New(args Args) (*Loader, error) { // We initialize the rand package now to make sure /dev/urandom is pre-opened // on kernels that do not support getrandom(2). if err := rand.Init(); err != nil { - return nil, fmt.Errorf("error setting up rand: %v", err) + return nil, fmt.Errorf("setting up rand: %v", err) } if err := usage.Init(); err != nil { - return nil, fmt.Errorf("error setting up memory usage: %v", err) + return nil, fmt.Errorf("setting up memory usage: %v", err) } // Create kernel and platform. p, err := createPlatform(args.Conf, args.DeviceFD) if err != nil { - return nil, fmt.Errorf("error creating platform: %v", err) + return nil, fmt.Errorf("creating platform: %v", err) } k := &kernel.Kernel{ Platform: p, @@ -194,18 +194,18 @@ func New(args Args) (*Loader, error) { // Pass k as the platform since it is savable, unlike the actual platform. vdso, err := loader.PrepareVDSO(k) if err != nil { - return nil, fmt.Errorf("error creating vdso: %v", err) + return nil, fmt.Errorf("creating vdso: %v", err) } // Create timekeeper. tk, err := kernel.NewTimekeeper(k, vdso.ParamPage.FileRange()) if err != nil { - return nil, fmt.Errorf("error creating timekeeper: %v", err) + return nil, fmt.Errorf("creating timekeeper: %v", err) } tk.SetClocks(time.NewCalibratedClocks()) if err := enableStrace(args.Conf); err != nil { - return nil, fmt.Errorf("failed to enable strace: %v", err) + return nil, fmt.Errorf("enabling strace: %v", err) } // Create an empty network stack because the network namespace may be empty at @@ -214,13 +214,13 @@ func New(args Args) (*Loader, error) { // Run(). networkStack, err := newEmptyNetworkStack(args.Conf, k) if err != nil { - return nil, fmt.Errorf("failed to create network: %v", err) + return nil, fmt.Errorf("creating network: %v", err) } // Create capabilities. caps, err := specutils.Capabilities(args.Spec.Process.Capabilities) if err != nil { - return nil, fmt.Errorf("error creating capabilities: %v", err) + return nil, fmt.Errorf("converting capabilities: %v", err) } // Convert the spec's additional GIDs to KGIDs. @@ -262,7 +262,7 @@ func New(args Args) (*Loader, error) { RootIPCNamespace: kernel.NewIPCNamespace(creds.UserNamespace), RootAbstractSocketNamespace: kernel.NewAbstractSocketNamespace(), }); err != nil { - return nil, fmt.Errorf("error initializing kernel: %v", err) + return nil, fmt.Errorf("initializing kernel: %v", err) } // Turn on packet logging if enabled. @@ -279,11 +279,11 @@ func New(args Args) (*Loader, error) { procArgs, err := newProcess(args.ID, args.Spec, creds, k) if err != nil { - return nil, fmt.Errorf("failed to create init process for root container: %v", err) + return nil, fmt.Errorf("creating init process for root container: %v", err) } if err := initCompatLogs(args.UserLogFD); err != nil { - return nil, fmt.Errorf("init compat logs: %v", err) + return nil, fmt.Errorf("initializing compat logs: %v", err) } eid := execID{cid: args.ID} @@ -303,7 +303,7 @@ func New(args Args) (*Loader, error) { // We don't care about child signals; some platforms can generate a // tremendous number of useless ones (I'm looking at you, ptrace). if err := sighandling.IgnoreChildStop(); err != nil { - return nil, fmt.Errorf("failed to ignore child stop signals: %v", err) + return nil, fmt.Errorf("ignore child stop signals failed: %v", err) } // Handle signals by forwarding them to the root container process @@ -353,7 +353,7 @@ func newProcess(id string, spec *specs.Spec, creds *auth.Credentials, k *kernel. // Create initial limits. ls, err := createLimitSet(spec) if err != nil { - return kernel.CreateProcessArgs{}, fmt.Errorf("error creating limits: %v", err) + return kernel.CreateProcessArgs{}, fmt.Errorf("creating limits: %v", err) } // Create the process arguments. @@ -441,7 +441,7 @@ func (l *Loader) run() error { ControllerFD: l.ctrl.srv.FD(), } if err := filter.Install(opts); err != nil { - return fmt.Errorf("Failed to install seccomp filters: %v", err) + return fmt.Errorf("installing seccomp filters: %v", err) } } @@ -465,13 +465,13 @@ func (l *Loader) run() error { rootCtx := l.rootProcArgs.NewContext(l.k) rootMns := l.k.RootMountNamespace() if err := setExecutablePath(rootCtx, rootMns, &l.rootProcArgs); err != nil { - return fmt.Errorf("error setting executable path for %+v: %v", l.rootProcArgs, err) + return err } // Create the root container init task. _, _, err := l.k.CreateProcess(l.rootProcArgs) if err != nil { - return fmt.Errorf("failed to create init process: %v", err) + return fmt.Errorf("creating init process: %v", err) } // CreateProcess takes a reference on FDMap if successful. @@ -521,7 +521,7 @@ func (l *Loader) startContainer(k *kernel.Kernel, spec *specs.Spec, conf *Config // Create capabilities. caps, err := specutils.Capabilities(spec.Process.Capabilities) if err != nil { - return fmt.Errorf("error creating capabilities: %v", err) + return fmt.Errorf("creating capabilities: %v", err) } // Convert the spec's additional GIDs to KGIDs. @@ -544,7 +544,7 @@ func (l *Loader) startContainer(k *kernel.Kernel, spec *specs.Spec, conf *Config procArgs, err := newProcess(cid, spec, creds, l.k) if err != nil { - return fmt.Errorf("failed to create new process: %v", err) + return fmt.Errorf("creating new process: %v", err) } // Can't take ownership away from os.File. dup them to get a new FDs. @@ -570,20 +570,20 @@ func (l *Loader) startContainer(k *kernel.Kernel, spec *specs.Spec, conf *Config procArgs.Limits, k, cid); err != nil { - return fmt.Errorf("failed to create new process: %v", err) + return fmt.Errorf("configuring container FS: %v", err) } // setFileSystemForProcess dup'd stdioFDs, so we can close them. for i, fd := range stdioFDs { if err := syscall.Close(fd); err != nil { - return fmt.Errorf("failed to close stdioFD #%d: %v", i, fd) + return fmt.Errorf("closing stdio FD #%d: %v", i, fd) } } ctx := procArgs.NewContext(l.k) mns := k.RootMountNamespace() if err := setExecutablePath(ctx, mns, &procArgs); err != nil { - return fmt.Errorf("error setting executable path for %+v: %v", procArgs, err) + return fmt.Errorf("setting executable path for %+v: %v", procArgs, err) } l.mu.Lock() @@ -596,7 +596,7 @@ func (l *Loader) startContainer(k *kernel.Kernel, spec *specs.Spec, conf *Config tg, _, err := l.k.CreateProcess(procArgs) if err != nil { - return fmt.Errorf("failed to create process in sentry: %v", err) + return fmt.Errorf("creating process: %v", err) } // CreateProcess takes a reference on FDMap if successful. procArgs.FDMap.DecRef() @@ -615,7 +615,7 @@ func (l *Loader) destroyContainer(cid string) error { if _, _, err := l.threadGroupFromIDLocked(execID{cid: cid}); err == nil { // If the container has started, kill and wait for all processes. if err := l.signalAllProcesses(cid, int32(linux.SIGKILL)); err != nil { - return fmt.Errorf("failed to SIGKILL all container processes: %v", err) + return fmt.Errorf("sending SIGKILL to all container processes: %v", err) } } @@ -628,7 +628,7 @@ func (l *Loader) destroyContainer(cid string) error { ctx := l.rootProcArgs.NewContext(l.k) if err := destroyContainerFS(ctx, cid, l.k); err != nil { - return fmt.Errorf("failed to destroy filesystem for container %q: %v", cid, err) + return fmt.Errorf("destroying filesystem for container %q: %v", cid, err) } // We made it! @@ -715,11 +715,11 @@ func (l *Loader) waitPID(tgid kernel.ThreadID, cid string, clearStatus bool, wai // In this case, find the process in the container's PID namespace. initTG, _, err := l.threadGroupFromID(execID{cid: cid}) if err != nil { - return fmt.Errorf("failed to wait for PID %d: %v", tgid, err) + return fmt.Errorf("waiting for PID %d: %v", tgid, err) } tg := initTG.PIDNamespace().ThreadGroupWithID(tgid) if tg == nil { - return fmt.Errorf("failed to wait for PID %d: no such process", tgid) + return fmt.Errorf("waiting for PID %d: no such process", tgid) } if tg.Leader().ContainerID() != cid { return fmt.Errorf("process %d is part of a different container: %q", tgid, tg.Leader().ContainerID()) @@ -778,15 +778,21 @@ func newEmptyNetworkStack(conf *Config, clock tcpip.Clock) (inet.Stack, error) { // processes in the container, or to the foreground process group. func (l *Loader) signal(cid string, pid, signo int32, mode SignalDeliveryMode) error { if pid < 0 { - return fmt.Errorf("failed to signal container %q PID %d: PID must be positive", cid, pid) + return fmt.Errorf("PID (%d) must be positive", pid) } switch mode { case DeliverToProcess: - return l.signalProcess(cid, kernel.ThreadID(pid), signo) + if err := l.signalProcess(cid, kernel.ThreadID(pid), signo); err != nil { + return fmt.Errorf("signaling process in container %q PID %d: %v", cid, pid, err) + } + return nil case DeliverToForegroundProcessGroup: - return l.signalForegrondProcessGroup(cid, kernel.ThreadID(pid), signo) + if err := l.signalForegrondProcessGroup(cid, kernel.ThreadID(pid), signo); err != nil { + return fmt.Errorf("signaling foreground process group in container %q PID %d: %v", cid, pid, err) + } + return nil case DeliverToAllProcesses: if pid != 0 { @@ -795,12 +801,15 @@ func (l *Loader) signal(cid string, pid, signo int32, mode SignalDeliveryMode) e // Check that the container has actually started before signaling it. _, _, err := l.threadGroupFromID(execID{cid: cid}) if err != nil { - return fmt.Errorf("failed to signal container %q: %v", cid, err) + return err } - return l.signalAllProcesses(cid, signo) + if err := l.signalAllProcesses(cid, signo); err != nil { + return fmt.Errorf("signaling all processes in container %q: %v", cid, err) + } + return nil default: - panic(fmt.Sprintf("unknown signal signal delivery mode %v", mode)) + panic(fmt.Sprintf("unknown signal delivery mode %v", mode)) } } @@ -816,11 +825,11 @@ func (l *Loader) signalProcess(cid string, tgid kernel.ThreadID, signo int32) er // signal it. initTG, _, err := l.threadGroupFromID(execID{cid: cid}) if err != nil { - return fmt.Errorf("failed to signal container %q: %v", cid, err) + return fmt.Errorf("no thread group found: %v", err) } tg := initTG.PIDNamespace().ThreadGroupWithID(tgid) if tg == nil { - return fmt.Errorf("failed to signal container %q PID %d: no such process", cid, tgid) + return fmt.Errorf("no such process with PID %d", tgid) } if tg.Leader().ContainerID() != cid { return fmt.Errorf("process %d is part of a different container: %q", tgid, tg.Leader().ContainerID()) @@ -833,10 +842,10 @@ func (l *Loader) signalForegrondProcessGroup(cid string, tgid kernel.ThreadID, s // and send the signal to it. tg, tty, err := l.threadGroupFromID(execID{cid: cid, pid: tgid}) if err != nil { - return fmt.Errorf("failed to signal foreground process group for container %q PID %d: %v", cid, tgid, err) + return fmt.Errorf("no thread group found: %v", err) } if tty == nil { - return fmt.Errorf("failed to signal foreground process group in container %q PID %d: no TTY attached", cid, tgid) + return fmt.Errorf("no TTY attached") } pg := tty.ForegroundProcessGroup() if pg == nil { diff --git a/runsc/cgroup/cgroup.go b/runsc/cgroup/cgroup.go index 65a0b6d7a..87f051e79 100644 --- a/runsc/cgroup/cgroup.go +++ b/runsc/cgroup/cgroup.go @@ -236,7 +236,7 @@ func (c *Cgroup) Uninstall() error { } return err }, b); err != nil { - return fmt.Errorf("error removing cgroup path %q: %v", path, err) + return fmt.Errorf("removing cgroup path %q: %v", path, err) } } return nil diff --git a/runsc/cmd/boot.go b/runsc/cmd/boot.go index fb1fd3e70..7f87b2623 100644 --- a/runsc/cmd/boot.go +++ b/runsc/cmd/boot.go @@ -154,7 +154,7 @@ func (b *Boot) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) defer specFile.Close() spec, err := specutils.ReadSpecFromFile(b.bundleDir, specFile) if err != nil { - Fatalf("error reading spec: %v", err) + Fatalf("reading spec: %v", err) } specutils.LogSpec(spec) @@ -208,7 +208,7 @@ func (b *Boot) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) } l, err := boot.New(bootArgs) if err != nil { - Fatalf("error creating loader: %v", err) + Fatalf("creating loader: %v", err) } // Fatalf exits the process and doesn't run defers. @@ -220,7 +220,7 @@ func (b *Boot) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) buf := make([]byte, 1) if w, err := startSyncFile.Write(buf); err != nil || w != 1 { l.Destroy() - Fatalf("Unable to write into the start-sync descriptor: %v", err) + Fatalf("unable to write into the start-sync descriptor: %v", err) } // Closes startSyncFile because 'l.Run()' only returns when the sandbox exits. startSyncFile.Close() @@ -231,7 +231,7 @@ func (b *Boot) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) // Run the application and wait for it to finish. if err := l.Run(); err != nil { l.Destroy() - Fatalf("error running sandbox: %v", err) + Fatalf("running sandbox: %v", err) } ws := l.WaitExit() diff --git a/runsc/cmd/checkpoint.go b/runsc/cmd/checkpoint.go index 4f4771da2..d8f748aa0 100644 --- a/runsc/cmd/checkpoint.go +++ b/runsc/cmd/checkpoint.go @@ -77,7 +77,7 @@ func (c *Checkpoint) Execute(_ context.Context, f *flag.FlagSet, args ...interfa cont, err := container.Load(conf.RootDir, id) if err != nil { - Fatalf("error loading container: %v", err) + Fatalf("loading container: %v", err) } if c.imagePath == "" { @@ -85,7 +85,7 @@ func (c *Checkpoint) Execute(_ context.Context, f *flag.FlagSet, args ...interfa } if err := os.MkdirAll(c.imagePath, 0755); err != nil { - Fatalf("error making directories at path provided: %v", err) + Fatalf("making directories at path provided: %v", err) } fullImagePath := filepath.Join(c.imagePath, checkpointFileName) @@ -115,12 +115,12 @@ func (c *Checkpoint) Execute(_ context.Context, f *flag.FlagSet, args ...interfa // Restore into new container with same ID. bundleDir := cont.BundleDir if bundleDir == "" { - Fatalf("error setting bundleDir") + Fatalf("setting bundleDir") } spec, err := specutils.ReadSpec(bundleDir) if err != nil { - Fatalf("error reading spec: %v", err) + Fatalf("reading spec: %v", err) } specutils.LogSpec(spec) @@ -130,17 +130,17 @@ func (c *Checkpoint) Execute(_ context.Context, f *flag.FlagSet, args ...interfa } if err := cont.Destroy(); err != nil { - Fatalf("error destroying container: %v", err) + Fatalf("destroying container: %v", err) } cont, err = container.Create(id, spec, conf, bundleDir, "", "", "") if err != nil { - Fatalf("error restoring container: %v", err) + Fatalf("restoring container: %v", err) } defer cont.Destroy() if err := cont.Restore(spec, conf, fullImagePath); err != nil { - Fatalf("error starting container: %v", err) + Fatalf("starting container: %v", err) } ws, err := cont.Wait() diff --git a/runsc/cmd/create.go b/runsc/cmd/create.go index d187b8592..30c8fa283 100644 --- a/runsc/cmd/create.go +++ b/runsc/cmd/create.go @@ -89,7 +89,7 @@ func (c *Create) Execute(_ context.Context, f *flag.FlagSet, args ...interface{} } spec, err := specutils.ReadSpec(bundleDir) if err != nil { - Fatalf("error reading spec: %v", err) + Fatalf("reading spec: %v", err) } specutils.LogSpec(spec) @@ -97,7 +97,7 @@ func (c *Create) Execute(_ context.Context, f *flag.FlagSet, args ...interface{} // container unless the metadata specifies that it should be run in an // existing container. if _, err := container.Create(id, spec, conf, bundleDir, c.consoleSocket, c.pidFile, c.userLog); err != nil { - Fatalf("error creating container: %v", err) + Fatalf("creating container: %v", err) } return subcommands.ExitSuccess } diff --git a/runsc/cmd/debug.go b/runsc/cmd/debug.go index de530c068..e10326754 100644 --- a/runsc/cmd/debug.go +++ b/runsc/cmd/debug.go @@ -68,7 +68,7 @@ func (d *Debug) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) var err error c, err = container.Load(conf.RootDir, f.Arg(0)) if err != nil { - Fatalf("error loading container %q: %v", f.Arg(0), err) + Fatalf("loading container %q: %v", f.Arg(0), err) } } else { if f.NArg() != 0 { @@ -78,12 +78,12 @@ func (d *Debug) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) // Go over all sandboxes and find the one that matches PID. ids, err := container.List(conf.RootDir) if err != nil { - Fatalf("error listing containers: %v", err) + Fatalf("listing containers: %v", err) } for _, id := range ids { candidate, err := container.Load(conf.RootDir, id) if err != nil { - Fatalf("error loading container %q: %v", id, err) + Fatalf("loading container %q: %v", id, err) } if candidate.SandboxPid() == d.pid { c = candidate @@ -110,7 +110,7 @@ func (d *Debug) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) log.Infof("Retrieving sandbox stacks") stacks, err := c.Sandbox.Stacks() if err != nil { - Fatalf("error retrieving stacks: %v", err) + Fatalf("retrieving stacks: %v", err) } log.Infof(" *** Stack dump ***\n%s", stacks) } diff --git a/runsc/cmd/delete.go b/runsc/cmd/delete.go index 8c7c7a5cd..3206b267a 100644 --- a/runsc/cmd/delete.go +++ b/runsc/cmd/delete.go @@ -74,13 +74,13 @@ func (d *Delete) execute(ids []string, conf *boot.Config) error { log.Warningf("couldn't find container %q: %v", id, err) return nil } - return fmt.Errorf("error loading container %q: %v", id, err) + return fmt.Errorf("loading container %q: %v", id, err) } if !d.force && c.Status != container.Created && c.Status != container.Stopped { return fmt.Errorf("cannot delete container that is not stopped without --force flag") } if err := c.Destroy(); err != nil { - return fmt.Errorf("error destroying container: %v", err) + return fmt.Errorf("destroying container: %v", err) } } return nil diff --git a/runsc/cmd/events.go b/runsc/cmd/events.go index a54856fb4..208d2f74b 100644 --- a/runsc/cmd/events.go +++ b/runsc/cmd/events.go @@ -76,7 +76,7 @@ func (evs *Events) Execute(ctx context.Context, f *flag.FlagSet, args ...interfa c, err := container.Load(conf.RootDir, id) if err != nil { - Fatalf("error loading sandbox: %v", err) + Fatalf("loading sandbox: %v", err) } // Repeatedly get stats from the container. @@ -84,13 +84,13 @@ func (evs *Events) Execute(ctx context.Context, f *flag.FlagSet, args ...interfa // Get the event and print it as JSON. ev, err := c.Event() if err != nil { - log.Warningf("error getting events for container: %v", err) + log.Warningf("Error getting events for container: %v", err) } // err must be preserved because it is used below when breaking // out of the loop. b, err := json.Marshal(ev) if err != nil { - log.Warningf("error while marshalling event %v: %v", ev, err) + log.Warningf("Error while marshalling event %v: %v", ev, err) } else { os.Stdout.Write(b) } diff --git a/runsc/cmd/exec.go b/runsc/cmd/exec.go index 548207222..13584d800 100644 --- a/runsc/cmd/exec.go +++ b/runsc/cmd/exec.go @@ -111,14 +111,14 @@ func (ex *Exec) SetFlags(f *flag.FlagSet) { func (ex *Exec) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) subcommands.ExitStatus { e, id, err := ex.parseArgs(f) if err != nil { - Fatalf("error parsing process spec: %v", err) + Fatalf("parsing process spec: %v", err) } conf := args[0].(*boot.Config) waitStatus := args[1].(*syscall.WaitStatus) c, err := container.Load(conf.RootDir, id) if err != nil { - Fatalf("error loading sandbox: %v", err) + Fatalf("loading sandbox: %v", err) } // Replace empty settings with defaults from container. @@ -128,13 +128,13 @@ func (ex *Exec) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) if e.Envv == nil { e.Envv, err = resolveEnvs(c.Spec.Process.Env, ex.env) if err != nil { - Fatalf("error getting environment variables: %v", err) + Fatalf("getting environment variables: %v", err) } } if e.Capabilities == nil { e.Capabilities, err = specutils.Capabilities(c.Spec.Process.Capabilities) if err != nil { - Fatalf("error creating capabilities: %v", err) + Fatalf("creating capabilities: %v", err) } } @@ -149,7 +149,7 @@ func (ex *Exec) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) // Start the new process and get it pid. pid, err := c.Execute(e) if err != nil { - Fatalf("error getting processes for container: %v", err) + Fatalf("getting processes for container: %v", err) } if e.StdioIsPty { @@ -163,7 +163,7 @@ func (ex *Exec) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) if ex.internalPidFile != "" { pidStr := []byte(strconv.Itoa(int(pid))) if err := ioutil.WriteFile(ex.internalPidFile, pidStr, 0644); err != nil { - Fatalf("error writing internal pid file %q: %v", ex.internalPidFile, err) + Fatalf("writing internal pid file %q: %v", ex.internalPidFile, err) } } @@ -172,14 +172,14 @@ func (ex *Exec) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) // returns. if ex.pidFile != "" { if err := ioutil.WriteFile(ex.pidFile, []byte(strconv.Itoa(os.Getpid())), 0644); err != nil { - Fatalf("error writing pid file: %v", err) + Fatalf("writing pid file: %v", err) } } // Wait for the process to exit. ws, err := c.WaitPID(pid, ex.clearStatus) if err != nil { - Fatalf("error waiting on pid %d: %v", pid, err) + Fatalf("waiting on pid %d: %v", pid, err) } *waitStatus = ws return subcommands.ExitSuccess @@ -188,7 +188,7 @@ func (ex *Exec) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) func (ex *Exec) execAndWait(waitStatus *syscall.WaitStatus) subcommands.ExitStatus { binPath, err := specutils.BinPath() if err != nil { - Fatalf("error getting bin path: %v", err) + Fatalf("getting bin path: %v", err) } var args []string @@ -199,7 +199,7 @@ func (ex *Exec) execAndWait(waitStatus *syscall.WaitStatus) subcommands.ExitStat if pidFile == "" { tmpDir, err := ioutil.TempDir("", "exec-pid-") if err != nil { - Fatalf("error creating TempDir: %v", err) + Fatalf("creating TempDir: %v", err) } defer os.RemoveAll(tmpDir) pidFile = filepath.Join(tmpDir, "pid") @@ -232,7 +232,7 @@ func (ex *Exec) execAndWait(waitStatus *syscall.WaitStatus) subcommands.ExitStat // socket. tty, err := console.NewWithSocket(ex.consoleSocket) if err != nil { - Fatalf("error setting up console with socket %q: %v", ex.consoleSocket, err) + Fatalf("setting up console with socket %q: %v", ex.consoleSocket, err) } defer tty.Close() @@ -307,7 +307,7 @@ func (ex *Exec) argsFromCLI(argv []string) (*control.ExecArgs, error) { for _, s := range ex.extraKGIDs { kgid, err := strconv.Atoi(s) if err != nil { - Fatalf("error parsing GID: %s, %v", s, err) + Fatalf("parsing GID: %s, %v", s, err) } extraKGIDs = append(extraKGIDs, auth.KGID(kgid)) } diff --git a/runsc/cmd/gofer.go b/runsc/cmd/gofer.go index 7276f3f26..43286a2e5 100644 --- a/runsc/cmd/gofer.go +++ b/runsc/cmd/gofer.go @@ -101,12 +101,12 @@ func (g *Gofer) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) specFile, err := specutils.OpenCleanSpec(g.bundleDir) if err != nil { - Fatalf("error opening spec: %v", err) + Fatalf("opening spec: %v", err) } spec, err := specutils.ReadSpecFromFile(g.bundleDir, specFile) specFile.Close() if err != nil { - Fatalf("error reading spec: %v", err) + Fatalf("reading spec: %v", err) } specutils.LogSpec(spec) @@ -120,7 +120,7 @@ func (g *Gofer) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) Fatalf("failed to chroot to %q: %v", root, err) } if err := syscall.Chdir("/"); err != nil { - Fatalf("failed to change working dir: %v", err) + Fatalf("changing working dir: %v", err) } log.Infof("Process chroot'd to %q", root) @@ -131,7 +131,7 @@ func (g *Gofer) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) PanicOnWrite: g.panicOnWrite, }) if err != nil { - Fatalf("Error creating attach point: %v", err) + Fatalf("creating attach point: %v", err) } ats = append(ats, ap) log.Infof("Serving %q mapped to %q on FD %d (ro: %t)", "/", root, g.ioFDs[0], spec.Root.Readonly) @@ -145,12 +145,12 @@ func (g *Gofer) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) } ap, err := fsgofer.NewAttachPoint(m.Destination, cfg) if err != nil { - Fatalf("Error creating attach point: %v", err) + Fatalf("creating attach point: %v", err) } ats = append(ats, ap) if mountIdx >= len(g.ioFDs) { - Fatalf("No FD found for mount. Did you forget --io-fd? mount: %d, %v", len(g.ioFDs), m) + Fatalf("no FD found for mount. Did you forget --io-fd? mount: %d, %v", len(g.ioFDs), m) } log.Infof("Serving %q mapped on FD %d (ro: %t)", m.Destination, g.ioFDs[mountIdx], cfg.ROMount) mountIdx++ @@ -161,7 +161,7 @@ func (g *Gofer) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) } if err := filter.Install(); err != nil { - Fatalf("Failed to install seccomp filters: %v", err) + Fatalf("installing seccomp filters: %v", err) } runServers(ats, g.ioFDs) @@ -176,7 +176,7 @@ func runServers(ats []p9.Attacher, ioFDs []int) { go func(ioFD int, at p9.Attacher) { socket, err := unet.NewSocket(ioFD) if err != nil { - Fatalf("err creating server on FD %d: %v", ioFD, err) + Fatalf("creating server on FD %d: %v", ioFD, err) } s := p9.NewServer(at) if err := s.Handle(socket); err != nil { diff --git a/runsc/cmd/kill.go b/runsc/cmd/kill.go index 7d86bb043..e67f82473 100644 --- a/runsc/cmd/kill.go +++ b/runsc/cmd/kill.go @@ -71,7 +71,7 @@ func (k *Kill) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) c, err := container.Load(conf.RootDir, id) if err != nil { - Fatalf("error loading container: %v", err) + Fatalf("loading container: %v", err) } // The OCI command-line spec says that the signal should be specified diff --git a/runsc/cmd/list.go b/runsc/cmd/list.go index acefcb2db..481066225 100644 --- a/runsc/cmd/list.go +++ b/runsc/cmd/list.go @@ -81,7 +81,7 @@ func (l *List) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) for _, id := range ids { c, err := container.Load(conf.RootDir, id) if err != nil { - Fatalf("error loading container %q: %v", id, err) + Fatalf("loading container %q: %v", id, err) } containers = append(containers, c) } @@ -108,7 +108,7 @@ func (l *List) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) states = append(states, c.State()) } if err := json.NewEncoder(os.Stdout).Encode(states); err != nil { - Fatalf("error marshaling container state: %v", err) + Fatalf("marshaling container state: %v", err) } default: Fatalf("unknown list format %q", l.format) diff --git a/runsc/cmd/path.go b/runsc/cmd/path.go index baba937a8..1276f0dbd 100644 --- a/runsc/cmd/path.go +++ b/runsc/cmd/path.go @@ -22,7 +22,7 @@ import ( func getwdOrDie() string { wd, err := os.Getwd() if err != nil { - Fatalf("error getting current working directory: %v", err) + Fatalf("getting current working directory: %v", err) } return wd } diff --git a/runsc/cmd/pause.go b/runsc/cmd/pause.go index ee608faba..2c93e5f3e 100644 --- a/runsc/cmd/pause.go +++ b/runsc/cmd/pause.go @@ -57,7 +57,7 @@ func (*Pause) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) s cont, err := container.Load(conf.RootDir, id) if err != nil { - Fatalf("error loading container: %v", err) + Fatalf("loading container: %v", err) } if err := cont.Pause(); err != nil { diff --git a/runsc/cmd/ps.go b/runsc/cmd/ps.go index fd76cf975..060d796f2 100644 --- a/runsc/cmd/ps.go +++ b/runsc/cmd/ps.go @@ -62,11 +62,11 @@ func (ps *PS) Execute(ctx context.Context, f *flag.FlagSet, args ...interface{}) c, err := container.Load(conf.RootDir, id) if err != nil { - Fatalf("error loading sandbox: %v", err) + Fatalf("loading sandbox: %v", err) } pList, err := c.Processes() if err != nil { - Fatalf("error getting processes for container: %v", err) + Fatalf("getting processes for container: %v", err) } switch ps.format { @@ -75,11 +75,11 @@ func (ps *PS) Execute(ctx context.Context, f *flag.FlagSet, args ...interface{}) case "json": o, err := control.PrintPIDsJSON(pList) if err != nil { - Fatalf("error generating JSON: %v", err) + Fatalf("generating JSON: %v", err) } fmt.Println(o) default: - Fatalf("Unsupported format: %s", ps.format) + Fatalf("unsupported format: %s", ps.format) } return subcommands.ExitSuccess diff --git a/runsc/cmd/restore.go b/runsc/cmd/restore.go index 64b302b0c..66b23c38e 100644 --- a/runsc/cmd/restore.go +++ b/runsc/cmd/restore.go @@ -84,7 +84,7 @@ func (r *Restore) Execute(_ context.Context, f *flag.FlagSet, args ...interface{ } spec, err := specutils.ReadSpec(bundleDir) if err != nil { - Fatalf("error reading spec: %v", err) + Fatalf("reading spec: %v", err) } specutils.LogSpec(spec) @@ -96,15 +96,15 @@ func (r *Restore) Execute(_ context.Context, f *flag.FlagSet, args ...interface{ c, err := container.Load(conf.RootDir, id) if err != nil { - Fatalf("error loading container: %v", err) + Fatalf("loading container: %v", err) } if err := c.Restore(spec, conf, restoreFile); err != nil { - Fatalf("error restoring container: %v", err) + Fatalf("restoring container: %v", err) } ws, err := c.Wait() if err != nil { - Fatalf("error running container: %v", err) + Fatalf("running container: %v", err) } *waitStatus = ws diff --git a/runsc/cmd/resume.go b/runsc/cmd/resume.go index e684aeb5c..5551d1450 100644 --- a/runsc/cmd/resume.go +++ b/runsc/cmd/resume.go @@ -58,7 +58,7 @@ func (r *Resume) Execute(_ context.Context, f *flag.FlagSet, args ...interface{} cont, err := container.Load(conf.RootDir, id) if err != nil { - Fatalf("error loading container: %v", err) + Fatalf("loading container: %v", err) } if err := cont.Resume(); err != nil { diff --git a/runsc/cmd/run.go b/runsc/cmd/run.go index 9a574679f..be1c1b678 100644 --- a/runsc/cmd/run.go +++ b/runsc/cmd/run.go @@ -69,13 +69,13 @@ func (r *Run) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) s } spec, err := specutils.ReadSpec(bundleDir) if err != nil { - Fatalf("error reading spec: %v", err) + Fatalf("reading spec: %v", err) } specutils.LogSpec(spec) ws, err := container.Run(id, spec, conf, bundleDir, r.consoleSocket, r.pidFile, r.userLog) if err != nil { - Fatalf("error running container: %v", err) + Fatalf("running container: %v", err) } *waitStatus = ws diff --git a/runsc/cmd/spec.go b/runsc/cmd/spec.go index ee306bfa6..063bd39c5 100644 --- a/runsc/cmd/spec.go +++ b/runsc/cmd/spec.go @@ -175,7 +175,7 @@ func (s *Spec) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) } if err := ioutil.WriteFile(confPath, specTemplate, 0664); err != nil { - Fatalf("error writing to %q: %v", confPath, err) + Fatalf("writing to %q: %v", confPath, err) } return subcommands.ExitSuccess diff --git a/runsc/cmd/start.go b/runsc/cmd/start.go index 065efec06..9e2e0c11d 100644 --- a/runsc/cmd/start.go +++ b/runsc/cmd/start.go @@ -56,10 +56,10 @@ func (*Start) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) s c, err := container.Load(conf.RootDir, id) if err != nil { - Fatalf("error loading container: %v", err) + Fatalf("loading container: %v", err) } if err := c.Start(conf); err != nil { - Fatalf("error starting container: %v", err) + Fatalf("starting container: %v", err) } return subcommands.ExitSuccess } diff --git a/runsc/cmd/state.go b/runsc/cmd/state.go index 15e27b250..c3ef65ab5 100644 --- a/runsc/cmd/state.go +++ b/runsc/cmd/state.go @@ -59,7 +59,7 @@ func (*State) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) s c, err := container.Load(conf.RootDir, id) if err != nil { - Fatalf("error loading container: %v", err) + Fatalf("loading container: %v", err) } log.Debugf("Returning state for container %+v", c) @@ -69,7 +69,7 @@ func (*State) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) s // Write json-encoded state directly to stdout. b, err := json.MarshalIndent(state, "", " ") if err != nil { - Fatalf("error marshaling container state: %v", err) + Fatalf("marshaling container state: %v", err) } os.Stdout.Write(b) return subcommands.ExitSuccess diff --git a/runsc/cmd/wait.go b/runsc/cmd/wait.go index 1e1c1fe17..6498dd15c 100644 --- a/runsc/cmd/wait.go +++ b/runsc/cmd/wait.go @@ -66,7 +66,7 @@ func (wt *Wait) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) } // You can't specify both -pid and -rootpid. if wt.rootPID != unsetPID && wt.pid != unsetPID { - Fatalf("only up to one of -pid and -rootPid can be set") + Fatalf("only one of -pid and -rootPid can be set") } id := f.Arg(0) @@ -74,7 +74,7 @@ func (wt *Wait) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) c, err := container.Load(conf.RootDir, id) if err != nil { - Fatalf("error loading container: %v", err) + Fatalf("loading container: %v", err) } var waitStatus syscall.WaitStatus @@ -83,21 +83,21 @@ func (wt *Wait) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) case wt.rootPID == unsetPID && wt.pid == unsetPID: ws, err := c.Wait() if err != nil { - Fatalf("error waiting on container %q: %v", c.ID, err) + Fatalf("waiting on container %q: %v", c.ID, err) } waitStatus = ws // Wait on a PID in the root PID namespace. case wt.rootPID != unsetPID: ws, err := c.WaitRootPID(int32(wt.rootPID), true /* clearStatus */) if err != nil { - Fatalf("error waiting on PID in root PID namespace %d in container %q: %v", wt.rootPID, c.ID, err) + Fatalf("waiting on PID in root PID namespace %d in container %q: %v", wt.rootPID, c.ID, err) } waitStatus = ws // Wait on a PID in the container's PID namespace. case wt.pid != unsetPID: ws, err := c.WaitPID(int32(wt.pid), true /* clearStatus */) if err != nil { - Fatalf("error waiting on PID %d in container %q: %v", wt.pid, c.ID, err) + Fatalf("waiting on PID %d in container %q: %v", wt.pid, c.ID, err) } waitStatus = ws } @@ -107,7 +107,7 @@ func (wt *Wait) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) } // Write json-encoded wait result directly to stdout. if err := json.NewEncoder(os.Stdout).Encode(result); err != nil { - Fatalf("error marshaling wait result: %v", err) + Fatalf("marshaling wait result: %v", err) } return subcommands.ExitSuccess } diff --git a/runsc/console/console.go b/runsc/console/console.go index 9f4f9214d..2eb9a8807 100644 --- a/runsc/console/console.go +++ b/runsc/console/console.go @@ -30,7 +30,7 @@ func NewWithSocket(socketPath string) (*os.File, error) { // Create a new pty master and slave. ptyMaster, ptySlave, err := pty.Open() if err != nil { - return nil, fmt.Errorf("error opening pty: %v", err) + return nil, fmt.Errorf("opening pty: %v", err) } defer ptyMaster.Close() @@ -38,7 +38,7 @@ func NewWithSocket(socketPath string) (*os.File, error) { conn, err := net.Dial("unix", socketPath) if err != nil { ptySlave.Close() - return nil, fmt.Errorf("error dial socket %q: %v", socketPath, err) + return nil, fmt.Errorf("dialing socket %q: %v", socketPath, err) } defer conn.Close() uc, ok := conn.(*net.UnixConn) @@ -49,7 +49,7 @@ func NewWithSocket(socketPath string) (*os.File, error) { socket, err := uc.File() if err != nil { ptySlave.Close() - return nil, fmt.Errorf("error getting file for unix socket %v: %v", uc, err) + return nil, fmt.Errorf("getting file for unix socket %v: %v", uc, err) } defer socket.Close() @@ -57,7 +57,7 @@ func NewWithSocket(socketPath string) (*os.File, error) { msg := unix.UnixRights(int(ptyMaster.Fd())) if err := unix.Sendmsg(int(socket.Fd()), []byte("pty-master"), msg, nil, 0); err != nil { ptySlave.Close() - return nil, fmt.Errorf("error sending console over unix socket %q: %v", socketPath, err) + return nil, fmt.Errorf("sending console over unix socket %q: %v", socketPath, err) } return ptySlave, nil } diff --git a/runsc/container/container.go b/runsc/container/container.go index 544e7a250..2d4b85d9f 100644 --- a/runsc/container/container.go +++ b/runsc/container/container.go @@ -137,7 +137,7 @@ type Container struct { func Load(rootDir, id string) (*Container, error) { log.Debugf("Load container %q %q", rootDir, id) if err := validateID(id); err != nil { - return nil, fmt.Errorf("error validating id: %v", err) + return nil, fmt.Errorf("validating id: %v", err) } cRoot, err := findContainerRoot(rootDir, id) @@ -162,11 +162,11 @@ func Load(rootDir, id string) (*Container, error) { // Preserve error so that callers can distinguish 'not found' errors. return nil, err } - return nil, fmt.Errorf("error reading container metadata file %q: %v", metaFile, err) + return nil, fmt.Errorf("reading container metadata file %q: %v", metaFile, err) } var c Container if err := json.Unmarshal(metaBytes, &c); err != nil { - return nil, fmt.Errorf("error unmarshaling container metadata from %q: %v", metaFile, err) + return nil, fmt.Errorf("unmarshaling container metadata from %q: %v", metaFile, err) } // If the status is "Running" or "Created", check that the sandbox @@ -225,7 +225,7 @@ func List(rootDir string) ([]string, error) { log.Debugf("List containers %q", rootDir) fs, err := ioutil.ReadDir(rootDir) if err != nil { - return nil, fmt.Errorf("ReadDir(%s) failed: %v", rootDir, err) + return nil, fmt.Errorf("reading dir %q: %v", rootDir, err) } var out []string for _, f := range fs { @@ -257,7 +257,7 @@ func Create(id string, spec *specs.Spec, conf *boot.Config, bundleDir, consoleSo if _, err := os.Stat(filepath.Join(containerRoot, metadataFilename)); err == nil { return nil, fmt.Errorf("container with id %q already exists", id) } else if !os.IsNotExist(err) { - return nil, fmt.Errorf("error looking for existing container in %q: %v", containerRoot, err) + return nil, fmt.Errorf("looking for existing container in %q: %v", containerRoot, err) } c := &Container{ @@ -446,14 +446,14 @@ func Run(id string, spec *specs.Spec, conf *boot.Config, bundleDir, consoleSocke log.Debugf("Run container %q in root dir: %s", id, conf.RootDir) c, err := Create(id, spec, conf, bundleDir, consoleSocket, pidFile, userLog) if err != nil { - return 0, fmt.Errorf("error creating container: %v", err) + return 0, fmt.Errorf("creating container: %v", err) } // Clean up partially created container if an error ocurrs. // Any errors returned by Destroy() itself are ignored. defer c.Destroy() if err := c.Start(conf); err != nil { - return 0, fmt.Errorf("error starting container: %v", err) + return 0, fmt.Errorf("starting container: %v", err) } return c.Wait() } @@ -595,7 +595,7 @@ func (c *Container) Pause() error { } if err := c.Sandbox.Pause(c.ID); err != nil { - return fmt.Errorf("error pausing container: %v", err) + return fmt.Errorf("pausing container: %v", err) } c.changeStatus(Paused) return c.save() @@ -615,7 +615,7 @@ func (c *Container) Resume() error { return fmt.Errorf("cannot resume container %q in state %v", c.ID, c.Status) } if err := c.Sandbox.Resume(c.ID); err != nil { - return fmt.Errorf("error resuming container: %v", err) + return fmt.Errorf("resuming container: %v", err) } c.changeStatus(Running) return c.save() @@ -657,19 +657,19 @@ func (c *Container) Destroy() error { var errs []string if err := c.stop(); err != nil { - err = fmt.Errorf("error stopping container: %v", err) + err = fmt.Errorf("stopping container: %v", err) log.Warningf("%v", err) errs = append(errs, err.Error()) } if err := destroyFS(c.Spec); err != nil { - err = fmt.Errorf("error destroying container fs: %v", err) + err = fmt.Errorf("destroying container fs: %v", err) log.Warningf("%v", err) errs = append(errs, err.Error()) } if err := os.RemoveAll(c.Root); err != nil && !os.IsNotExist(err) { - err = fmt.Errorf("error deleting container root directory %q: %v", c.Root, err) + err = fmt.Errorf("deleting container root directory %q: %v", c.Root, err) log.Warningf("%v", err) errs = append(errs, err.Error()) } @@ -702,10 +702,10 @@ func (c *Container) save() error { metaFile := filepath.Join(c.Root, metadataFilename) meta, err := json.Marshal(c) if err != nil { - return fmt.Errorf("error marshaling container metadata: %v", err) + return fmt.Errorf("invalid container metadata: %v", err) } if err := ioutil.WriteFile(metaFile, meta, 0640); err != nil { - return fmt.Errorf("error writing container metadata: %v", err) + return fmt.Errorf("writing container metadata: %v", err) } return nil } @@ -719,7 +719,7 @@ func (c *Container) stop() error { if c.Sandbox != nil { log.Debugf("Destroying container %q", c.ID) if err := c.Sandbox.DestroyContainer(c.ID); err != nil { - return fmt.Errorf("error destroying container %q: %v", c.ID, err) + return fmt.Errorf("destroying container %q: %v", c.ID, err) } cgroup = c.Sandbox.Cgroup // Only set sandbox to nil after it has been told to destroy the container. @@ -917,12 +917,12 @@ func (c *Container) lock() (func() error, error) { // given container root directory. func lockContainerMetadata(containerRootDir string) (func() error, error) { if err := os.MkdirAll(containerRootDir, 0711); err != nil { - return nil, fmt.Errorf("error creating container root directory %q: %v", containerRootDir, err) + return nil, fmt.Errorf("creating container root directory %q: %v", containerRootDir, err) } f := filepath.Join(containerRootDir, metadataLockFilename) l := flock.NewFlock(f) if err := l.Lock(); err != nil { - return nil, fmt.Errorf("error acquiring lock on container lock file %q: %v", f, err) + return nil, fmt.Errorf("acquiring lock on container lock file %q: %v", f, err) } return l.Unlock, nil } diff --git a/runsc/container/fs.go b/runsc/container/fs.go index 97195550f..998160487 100644 --- a/runsc/container/fs.go +++ b/runsc/container/fs.go @@ -94,14 +94,14 @@ func setupFS(spec *specs.Spec, conf *boot.Config, bundleDir string) ([]specs.Mou flags |= syscall.MS_BIND log.Infof("Mounting src: %q, dst: %q, flags: %#x", m.Source, dst, flags) if err := specutils.Mount(m.Source, dst, m.Type, flags); err != nil { - return nil, fmt.Errorf("failed to mount %v: %v", m, err) + return nil, fmt.Errorf("mounting %v: %v", m, err) } // Make the mount a slave, so that for recursive bind mount, umount won't // propagate to the source. flags = syscall.MS_SLAVE | syscall.MS_REC if err := syscall.Mount("", dst, "", uintptr(flags), ""); err != nil { - return nil, fmt.Errorf("failed to rslave mount dst: %q, flags: %#x, err: %v", dst, flags, err) + return nil, fmt.Errorf("mount rslave dst: %q, flags: %#x, err: %v", dst, flags, err) } cpy := m @@ -146,7 +146,7 @@ func setupFS(spec *specs.Spec, conf *boot.Config, bundleDir string) ([]specs.Mou flags := uintptr(syscall.MS_BIND | syscall.MS_REMOUNT | syscall.MS_RDONLY | syscall.MS_REC) src := spec.Root.Path if err := syscall.Mount(src, src, "bind", flags, ""); err != nil { - return nil, fmt.Errorf("failed to remount root as read-only with source: %q, target: %q, flags: %#x, err: %v", spec.Root.Path, spec.Root.Path, flags, err) + return nil, fmt.Errorf("remounting root as read-only with source: %q, target: %q, flags: %#x, err: %v", spec.Root.Path, spec.Root.Path, flags, err) } } return rv, nil diff --git a/runsc/sandbox/network.go b/runsc/sandbox/network.go index 52fe8fc0f..8ec320d09 100644 --- a/runsc/sandbox/network.go +++ b/runsc/sandbox/network.go @@ -61,19 +61,19 @@ func setupNetwork(conn *urpc.Client, pid int, spec *specs.Spec, conf *boot.Confi case boot.NetworkNone: log.Infof("Network is disabled, create loopback interface only") if err := createDefaultLoopbackInterface(conn); err != nil { - return fmt.Errorf("error creating default loopback interface: %v", err) + return fmt.Errorf("creating default loopback interface: %v", err) } case boot.NetworkSandbox: // Build the path to the net namespace of the sandbox process. // This is what we will copy. nsPath := filepath.Join("/proc", strconv.Itoa(pid), "ns/net") if err := createInterfacesAndRoutesFromNS(conn, nsPath); err != nil { - return fmt.Errorf("error creating interfaces from net namespace %q: %v", nsPath, err) + return fmt.Errorf("creating interfaces from net namespace %q: %v", nsPath, err) } case boot.NetworkHost: // Nothing to do here. default: - return fmt.Errorf("Invalid network type: %d", conf.Network) + return fmt.Errorf("invalid network type: %d", conf.Network) } return nil } @@ -99,7 +99,7 @@ func createDefaultLoopbackInterface(conn *urpc.Client) error { if err := conn.Call(boot.NetworkCreateLinksAndRoutes, &boot.CreateLinksAndRoutesArgs{ LoopbackLinks: []boot.LoopbackLink{link}, }, nil); err != nil { - return fmt.Errorf("error creating loopback link and routes: %v", err) + return fmt.Errorf("creating loopback link and routes: %v", err) } return nil } @@ -112,7 +112,7 @@ func joinNetNS(nsPath string) (func(), error) { }) if err != nil { runtime.UnlockOSThread() - return nil, fmt.Errorf("error joining net namespace %q: %v", nsPath, err) + return nil, fmt.Errorf("joining net namespace %q: %v", nsPath, err) } return func() { restoreNS() @@ -147,7 +147,7 @@ func createInterfacesAndRoutesFromNS(conn *urpc.Client, nsPath string) error { // Get all interfaces in the namespace. ifaces, err := net.Interfaces() if err != nil { - return fmt.Errorf("error querying interfaces: %v", err) + return fmt.Errorf("querying interfaces: %v", err) } if isRootNS(ifaces) { @@ -164,14 +164,14 @@ func createInterfacesAndRoutesFromNS(conn *urpc.Client, nsPath string) error { allAddrs, err := iface.Addrs() if err != nil { - return fmt.Errorf("error fetching interface addresses for %q: %v", iface.Name, err) + return fmt.Errorf("fetching interface addresses for %q: %v", iface.Name, err) } // We build our own loopback devices. if iface.Flags&net.FlagLoopback != 0 { links, err := loopbackLinks(iface, allAddrs) if err != nil { - return fmt.Errorf("error getting loopback routes and links for iface %q: %v", iface.Name, err) + return fmt.Errorf("getting loopback routes and links for iface %q: %v", iface.Name, err) } args.LoopbackLinks = append(args.LoopbackLinks, links...) continue @@ -218,7 +218,7 @@ func createInterfacesAndRoutesFromNS(conn *urpc.Client, nsPath string) error { // will remove the routes as well. routes, def, err := routesForIface(iface) if err != nil { - return fmt.Errorf("error getting routes for interface %q: %v", iface.Name, err) + return fmt.Errorf("getting routes for interface %q: %v", iface.Name, err) } if def != nil { if !args.DefaultGateway.Route.Empty() { @@ -237,7 +237,7 @@ func createInterfacesAndRoutesFromNS(conn *urpc.Client, nsPath string) error { // Get the link for the interface. ifaceLink, err := netlink.LinkByName(iface.Name) if err != nil { - return fmt.Errorf("error getting link for interface %q: %v", iface.Name, err) + return fmt.Errorf("getting link for interface %q: %v", iface.Name, err) } // Collect the addresses for the interface, enable forwarding, @@ -247,7 +247,7 @@ func createInterfacesAndRoutesFromNS(conn *urpc.Client, nsPath string) error { // Steal IP address from NIC. if err := removeAddress(ifaceLink, addr.String()); err != nil { - return fmt.Errorf("error removing address %v from device %q: %v", iface.Name, addr, err) + return fmt.Errorf("removing address %v from device %q: %v", iface.Name, addr, err) } } @@ -257,7 +257,7 @@ func createInterfacesAndRoutesFromNS(conn *urpc.Client, nsPath string) error { log.Debugf("Setting up network, config: %+v", args) if err := conn.Call(boot.NetworkCreateLinksAndRoutes, &args, nil); err != nil { - return fmt.Errorf("error creating links and routes: %v", err) + return fmt.Errorf("creating links and routes: %v", err) } return nil } @@ -291,7 +291,7 @@ func routesForIface(iface net.Interface) ([]boot.Route, *boot.Route, error) { } rs, err := netlink.RouteList(link, netlink.FAMILY_ALL) if err != nil { - return nil, nil, fmt.Errorf("error getting routes from %q: %v", iface.Name, err) + return nil, nil, fmt.Errorf("getting routes from %q: %v", iface.Name, err) } var def *boot.Route diff --git a/runsc/sandbox/sandbox.go b/runsc/sandbox/sandbox.go index df4c3c787..53cb464d2 100644 --- a/runsc/sandbox/sandbox.go +++ b/runsc/sandbox/sandbox.go @@ -100,7 +100,7 @@ func New(id string, spec *specs.Spec, conf *boot.Config, bundleDir, consoleSocke // Wait until the sandbox has booted. b := make([]byte, 1) if l, err := clientSyncFile.Read(b); err != nil || l != 1 { - return nil, fmt.Errorf("error reading from the start-sync descriptor: %v", err) + return nil, fmt.Errorf("reading from the start-sync descriptor: %v", err) } c.Release() @@ -133,13 +133,13 @@ func (s *Sandbox) StartRoot(spec *specs.Spec, conf *boot.Config) error { // Configure the network. if err := setupNetwork(conn, s.Pid, spec, conf); err != nil { - return fmt.Errorf("error setting up network: %v", err) + return fmt.Errorf("setting up network: %v", err) } // Send a message to the sandbox control server to start the root // container. if err := conn.Call(boot.RootContainerStart, &s.ID, nil); err != nil { - return fmt.Errorf("error starting root container %v: %v", spec.Process.Args, err) + return fmt.Errorf("starting root container: %v", err) } return nil @@ -169,18 +169,18 @@ func (s *Sandbox) StartContainer(spec *specs.Spec, conf *boot.Config, cid string FilePayload: urpc.FilePayload{Files: files}, } if err := sandboxConn.Call(boot.ContainerStart, &args, nil); err != nil { - return fmt.Errorf("error starting non-root container %v: %v", spec.Process.Args, err) + return fmt.Errorf("starting non-root container %v: %v", spec.Process.Args, err) } return nil } // Restore sends the restore call for a container in the sandbox. -func (s *Sandbox) Restore(cid string, spec *specs.Spec, conf *boot.Config, f string) error { +func (s *Sandbox) Restore(cid string, spec *specs.Spec, conf *boot.Config, filename string) error { log.Debugf("Restore sandbox %q", s.ID) - rf, err := os.Open(f) + rf, err := os.Open(filename) if err != nil { - return fmt.Errorf("os.Open(%q) failed: %v", f, err) + return fmt.Errorf("opening restore file %q failed: %v", filename, err) } defer rf.Close() @@ -207,12 +207,12 @@ func (s *Sandbox) Restore(cid string, spec *specs.Spec, conf *boot.Config, f str // Configure the network. if err := setupNetwork(conn, s.Pid, spec, conf); err != nil { - return fmt.Errorf("error setting up network: %v", err) + return fmt.Errorf("setting up network: %v", err) } // Restore the container and start the root container. if err := conn.Call(boot.ContainerRestore, &opt, nil); err != nil { - return fmt.Errorf("error restoring container %q: %v", cid, err) + return fmt.Errorf("restoring container %q: %v", cid, err) } return nil @@ -230,7 +230,7 @@ func (s *Sandbox) Processes(cid string) ([]*control.Process, error) { var pl []*control.Process if err := conn.Call(boot.ContainerProcesses, &cid, &pl); err != nil { - return nil, fmt.Errorf("error retrieving process data from sandbox: %v", err) + return nil, fmt.Errorf("retrieving process data from sandbox: %v", err) } return pl, nil } @@ -248,7 +248,7 @@ func (s *Sandbox) Execute(args *control.ExecArgs) (int32, error) { // Send a message to the sandbox control server to start the container. var pid int32 if err := conn.Call(boot.ContainerExecuteAsync, args, &pid); err != nil { - return 0, fmt.Errorf("error executing command %q in sandbox: %v", args, err) + return 0, fmt.Errorf("executing command %q in sandbox: %v", args, err) } return pid, nil } @@ -266,7 +266,7 @@ func (s *Sandbox) Event(cid string) (*boot.Event, error) { // TODO: Pass in the container id (cid) here. The sandbox // should return events only for that container. if err := conn.Call(boot.ContainerEvent, nil, &e); err != nil { - return nil, fmt.Errorf("error retrieving event data from sandbox: %v", err) + return nil, fmt.Errorf("retrieving event data from sandbox: %v", err) } e.ID = cid return &e, nil @@ -282,7 +282,7 @@ func (s *Sandbox) sandboxConnect() (*urpc.Client, error) { } func (s *Sandbox) connError(err error) error { - return fmt.Errorf("error connecting to control server at PID %d: %v", s.Pid, err) + return fmt.Errorf("connecting to control server at PID %d: %v", s.Pid, err) } // createSandboxProcess starts the sandbox as a subprocess by running the "boot" @@ -305,7 +305,7 @@ func (s *Sandbox) createSandboxProcess(spec *specs.Spec, conf *boot.Config, bund if conf.LogFilename != "" { logFile, err := os.OpenFile(conf.LogFilename, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) if err != nil { - return fmt.Errorf("error opening log file %q: %v", conf.LogFilename, err) + return fmt.Errorf("opening log file %q: %v", conf.LogFilename, err) } defer logFile.Close() cmd.ExtraFiles = append(cmd.ExtraFiles, logFile) @@ -315,7 +315,7 @@ func (s *Sandbox) createSandboxProcess(spec *specs.Spec, conf *boot.Config, bund if conf.DebugLog != "" { debugLogFile, err := specutils.DebugLogFile(conf.DebugLog, "boot") if err != nil { - return fmt.Errorf("error opening debug log file in %q: %v", conf.DebugLog, err) + return fmt.Errorf("opening debug log file in %q: %v", conf.DebugLog, err) } defer debugLogFile.Close() cmd.ExtraFiles = append(cmd.ExtraFiles, debugLogFile) @@ -333,7 +333,7 @@ func (s *Sandbox) createSandboxProcess(spec *specs.Spec, conf *boot.Config, bund sockFD, err := server.CreateSocket(addr) log.Infof("Creating sandbox process with addr: %s", addr[1:]) // skip "\00". if err != nil { - return fmt.Errorf("error creating control server socket for sandbox %q: %v", s.ID, err) + return fmt.Errorf("creating control server socket for sandbox %q: %v", s.ID, err) } controllerFile := os.NewFile(uintptr(sockFD), "control_server_socket") defer controllerFile.Close() @@ -391,7 +391,7 @@ func (s *Sandbox) createSandboxProcess(spec *specs.Spec, conf *boot.Config, bund // socket, and return the slave. tty, err := console.NewWithSocket(consoleSocket) if err != nil { - return fmt.Errorf("error setting up console with socket %q: %v", consoleSocket, err) + return fmt.Errorf("setting up console with socket %q: %v", consoleSocket, err) } defer tty.Close() @@ -558,13 +558,13 @@ func (s *Sandbox) createSandboxProcess(spec *specs.Spec, conf *boot.Config, bund if s.Cgroup != nil { cpuNum, err := s.Cgroup.NumCPU() if err != nil { - return fmt.Errorf("error getting cpu count from cgroups: %v", err) + return fmt.Errorf("getting cpu count from cgroups: %v", err) } cmd.Args = append(cmd.Args, "--cpu-num", strconv.Itoa(cpuNum)) mem, err := s.Cgroup.MemoryLimit() if err != nil { - return fmt.Errorf("error getting memory limit from cgroups: %v", err) + return fmt.Errorf("getting memory limit from cgroups: %v", err) } // When memory limit is unset, a "large" number is returned. In that case, // just stick with the default. @@ -636,7 +636,7 @@ func (s *Sandbox) Wait(cid string) (syscall.WaitStatus, error) { // "On Unix systems, FindProcess always succeeds and returns a // Process for the given pid, regardless of whether the process // exists." - return ws, fmt.Errorf("FindProcess(%d) failed: %v", s.Pid, err) + return ws, fmt.Errorf("Find process %d: %v", s.Pid, err) } ps, err := p.Wait() if err != nil { @@ -662,7 +662,7 @@ func (s *Sandbox) WaitPID(cid string, pid int32, clearStatus bool) (syscall.Wait ClearStatus: clearStatus, } if err := conn.Call(boot.ContainerWaitPID, args, &ws); err != nil { - return ws, fmt.Errorf("error waiting on PID %d in sandbox %q: %v", pid, s.ID, err) + return ws, fmt.Errorf("waiting on PID %d in sandbox %q: %v", pid, s.ID, err) } return ws, nil } @@ -680,10 +680,10 @@ func (s *Sandbox) destroy() error { if s.Pid != 0 { log.Debugf("Killing sandbox %q", s.ID) if err := syscall.Kill(s.Pid, syscall.SIGKILL); err != nil && err != syscall.ESRCH { - return fmt.Errorf("error killing sandbox %q PID %q: %v", s.ID, s.Pid, err) + return fmt.Errorf("killing sandbox %q PID %q: %v", s.ID, s.Pid, err) } if err := s.waitForStopped(); err != nil { - return fmt.Errorf("error waiting sandbox %q stop: %v", s.ID, err) + return fmt.Errorf("waiting sandbox %q stop: %v", s.ID, err) } } @@ -712,7 +712,7 @@ func (s *Sandbox) SignalContainer(cid string, sig syscall.Signal, all bool) erro Mode: mode, } if err := conn.Call(boot.ContainerSignal, &args, nil); err != nil { - return fmt.Errorf("err signaling container %q: %v", cid, err) + return fmt.Errorf("signaling container %q: %v", cid, err) } return nil } @@ -741,7 +741,7 @@ func (s *Sandbox) SignalProcess(cid string, pid int32, sig syscall.Signal, fgPro Mode: mode, } if err := conn.Call(boot.ContainerSignal, &args, nil); err != nil { - return fmt.Errorf("err signaling container %q PID %d: %v", cid, pid, err) + return fmt.Errorf("signaling container %q PID %d: %v", cid, pid, err) } return nil } @@ -763,7 +763,7 @@ func (s *Sandbox) Checkpoint(cid string, f *os.File) error { } if err := conn.Call(boot.ContainerCheckpoint, &opt, nil); err != nil { - return fmt.Errorf("err checkpointing container %q: %v", cid, err) + return fmt.Errorf("checkpointing container %q: %v", cid, err) } return nil } @@ -778,7 +778,7 @@ func (s *Sandbox) Pause(cid string) error { defer conn.Close() if err := conn.Call(boot.ContainerPause, nil, nil); err != nil { - return fmt.Errorf("err pausing container %q: %v", cid, err) + return fmt.Errorf("pausing container %q: %v", cid, err) } return nil } @@ -793,7 +793,7 @@ func (s *Sandbox) Resume(cid string) error { defer conn.Close() if err := conn.Call(boot.ContainerResume, nil, nil); err != nil { - return fmt.Errorf("err resuming container %q: %v", cid, err) + return fmt.Errorf("resuming container %q: %v", cid, err) } return nil } @@ -821,7 +821,7 @@ func (s *Sandbox) Stacks() (string, error) { var stacks string if err := conn.Call(boot.SandboxStacks, nil, &stacks); err != nil { - return "", fmt.Errorf("err getting sandbox %q stacks: %v", s.ID, err) + return "", fmt.Errorf("getting sandbox %q stacks: %v", s.ID, err) } return stacks, nil } @@ -846,7 +846,7 @@ func (s *Sandbox) DestroyContainer(cid string) error { } defer conn.Close() if err := conn.Call(boot.ContainerDestroy, &cid, nil); err != nil { - return fmt.Errorf("error destroying container %q: %v", cid, err) + return fmt.Errorf("destroying container %q: %v", cid, err) } return nil } @@ -889,7 +889,7 @@ func deviceFileForPlatform(p boot.PlatformType) (*os.File, error) { return nil, nil } if err != nil { - return nil, fmt.Errorf("error opening device file for platform %q: %v", p, err) + return nil, fmt.Errorf("opening device file for platform %q: %v", p, err) } return f, err } |