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/sandbox/network.go | |
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/sandbox/network.go')
-rw-r--r-- | runsc/sandbox/network.go | 26 |
1 files changed, 13 insertions, 13 deletions
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 |