Skip to content

Commit

Permalink
Merge pull request moby#30615 from tiborvass/plugin_errors
Browse files Browse the repository at this point in the history
plugin: use pkg/errors in more places
  • Loading branch information
vdemeester authored Feb 1, 2017
2 parents deb0885 + 26d0bac commit 60f8f3f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion api/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func (s *Server) makeHTTPHandler(handler httputils.APIFunc) http.HandlerFunc {
}

if err := handlerFunc(ctx, w, r, vars); err != nil {
logrus.Errorf("Handler for %s %s returned error: %v", r.Method, r.URL.Path, err)
logrus.Errorf("Handler for %s %s returned error: %+v", r.Method, r.URL.Path, err)
httputils.MakeErrorHandler(err)(w, r)
}
}
Expand Down
2 changes: 1 addition & 1 deletion plugin/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func (pm *Manager) save(p *v2.Plugin) error {
return errors.Wrap(err, "failed to marshal plugin json")
}
if err := ioutils.AtomicWriteFile(filepath.Join(pm.config.Root, p.GetID(), configFileName), pluginJSON, 0600); err != nil {
return err
return errors.Wrap(err, "failed to write atomically plugin json")
}
return nil
}
Expand Down
8 changes: 4 additions & 4 deletions plugin/manager_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ func (pm *Manager) enable(p *v2.Plugin, c *controller, force bool) error {

if p.PropagatedMount != "" {
if err := mount.MakeRShared(p.PropagatedMount); err != nil {
return err
return errors.WithStack(err)
}
}

if err := initlayer.Setup(filepath.Join(pm.config.Root, p.PluginObj.ID, rootFSFileName), 0, 0); err != nil {
return err
return errors.WithStack(err)
}

if err := pm.containerdClient.Create(p.GetID(), "", "", specs.Spec(*spec), attachToLog(p.GetID())); err != nil {
Expand All @@ -56,7 +56,7 @@ func (pm *Manager) enable(p *v2.Plugin, c *controller, force bool) error {
logrus.Warnf("Could not unmount %s: %v", p.PropagatedMount, err)
}
}
return err
return errors.WithStack(err)
}

return pm.pluginPostStart(p, c)
Expand All @@ -67,7 +67,7 @@ func (pm *Manager) pluginPostStart(p *v2.Plugin, c *controller) error {
if err != nil {
c.restart = false
shutdownPlugin(p, c, pm.containerdClient)
return err
return errors.WithStack(err)
}

p.SetPClient(client)
Expand Down
6 changes: 3 additions & 3 deletions plugin/v2/plugin_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
package v2

import (
"errors"
"os"
"path/filepath"
"strings"
Expand All @@ -12,6 +11,7 @@ import (
"github.com/docker/docker/oci"
"github.com/docker/docker/pkg/system"
specs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors"
)

// InitSpec creates an OCI spec from the plugin's config.
Expand All @@ -29,7 +29,7 @@ func (p *Plugin) InitSpec(execRoot string) (*specs.Spec, error) {

execRoot = filepath.Join(execRoot, p.PluginObj.ID)
if err := os.MkdirAll(execRoot, 0700); err != nil {
return nil, err
return nil, errors.WithStack(err)
}

mounts := append(p.PluginObj.Config.Mounts, types.PluginMount{
Expand Down Expand Up @@ -95,7 +95,7 @@ func (p *Plugin) InitSpec(execRoot string) (*specs.Spec, error) {
path := *dev.Path
d, dPermissions, err := oci.DevicesFromPath(path, path, "rwm")
if err != nil {
return nil, err
return nil, errors.WithStack(err)
}
s.Linux.Devices = append(s.Linux.Devices, d...)
s.Linux.Resources.Devices = append(s.Linux.Resources.Devices, dPermissions...)
Expand Down

0 comments on commit 60f8f3f

Please sign in to comment.