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
This commit is contained in:
Fabricio Voznika
2019-01-18 17:36:02 -08:00
committed by Shentubot
parent c0a981629c
commit c1be25b78d
29 changed files with 211 additions and 201 deletions
+6 -6
View File
@@ -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
+22 -21
View File
@@ -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
+45 -36
View File
@@ -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 {
+1 -1
View File
@@ -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
+4 -4
View File
@@ -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()
+7 -7
View File
@@ -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()
+2 -2
View File
@@ -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
}
+4 -4
View File
@@ -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)
}
+2 -2
View File
@@ -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
+3 -3
View File
@@ -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)
}
+12 -12
View File
@@ -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))
}
+8 -8
View File
@@ -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 {
+1 -1
View File
@@ -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
+2 -2
View File
@@ -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)
+1 -1
View File
@@ -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
}
+1 -1
View File
@@ -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 {
+4 -4
View File
@@ -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
+4 -4
View File
@@ -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
+1 -1
View File
@@ -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 {
+2 -2
View File
@@ -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

Some files were not shown because too many files have changed in this diff Show More