Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap some driver-level errors #73

Merged
merged 1 commit into from
Jul 11, 2017
Merged

Conversation

nalind
Copy link
Member

@nalind nalind commented Jul 7, 2017

Wrap graphdriver.{ErrNotSupported,ErrPrerequisites,ErrIncompatibleFS} errors in contexts using github.com/pkg/errors, and dig them out for comparison using errors.Cause().

@@ -27,8 +27,10 @@ import (
"github.com/containers/storage/pkg/idtools"
"github.com/containers/storage/pkg/mount"
"github.com/containers/storage/pkg/parsers"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you add this space.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At some point, various source files appear to have been grouping import statements into standard library, packages that are part of this repository, and vendored code, but it's inconsistent. I had started trying to clean that up, but it can wait.

"github.com/containers/storage/drivers"
"github.com/containers/storage/pkg/idtools"
"github.com/containers/storage/pkg/mount"
"github.com/containers/storage/pkg/parsers"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit remove space.

@@ -6,6 +6,8 @@ import (
"syscall"

"github.com/Sirupsen/logrus"
"github.com/pkg/errors"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't add space.

@@ -18,7 +20,7 @@ func checkRootdirFs(rootdir string) error {
// on FreeBSD buf.Fstypename contains ['z', 'f', 's', 0 ... ]
if (buf.Fstypename[0] != 122) || (buf.Fstypename[1] != 102) || (buf.Fstypename[2] != 115) || (buf.Fstypename[3] != 0) {
logrus.Debugf("[zfs] no zfs dataset found for rootdir '%s'", rootdir)
return graphdriver.ErrPrerequisites
return errors.Wrapf(graphdriver.ErrPrerequisites, "%q is not on a zfs filesystem", rootdir)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come logrus and error message don't match?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy+paste error, fixing.

@@ -5,6 +5,8 @@ import (
"syscall"

"github.com/Sirupsen/logrus"
"github.com/pkg/errors"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove space

@@ -227,7 +227,8 @@ func New(root string, name string, options []string, uidMaps, gidMaps []idtools.

// isDriverNotSupported returns true if the error initializing
// the graph driver is a non-supported error.
func isDriverNotSupported(err error) bool {
func isDriverNotSupported(werr error) bool {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, I would leave interface as err and then use werr inside.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. Renaming werr to cause if we're going to change that line anyway.

@@ -56,7 +57,7 @@ func Mounted(fsType FsMagic, mountPath string) (bool, error) {
(buf.f_basetype[3] != 0) {
log.Debugf("[zfs] no zfs dataset found for rootdir '%s'", mountPath)
C.free(unsafe.Pointer(buf))
return false, ErrPrerequisites
return false, errors.Wrapf(graphdriver.ErrPrerequisites, "%q is not on a zfs filesystem", mountPath)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shold log message and error match?

@@ -26,7 +23,9 @@ import (
"github.com/containers/storage/pkg/parsers"
"github.com/containers/storage/pkg/parsers/kernel"

"github.com/Sirupsen/logrus"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove newline above?

drivers/proxy.go Outdated
"fmt"

"github.com/pkg/errors"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove newline.

@@ -23,14 +23,15 @@ import (
"github.com/Microsoft/go-winio/backuptar"
"github.com/Microsoft/hcsshim"
"github.com/Sirupsen/logrus"
"github.com/vbatts/tar-split/tar/storage"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove newline.

@rhatdan
Copy link
Member

rhatdan commented Jul 10, 2017

Looks like this pull request replaces #70

Wrap graphdriver.{ErrNotSupported,ErrPrerequisites,ErrIncompatibleFS}
errors in contexts using github.com/pkg/errors, and dig them out for
comparison using errors.Cause().

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
@nalind
Copy link
Member Author

nalind commented Jul 10, 2017

Updated, undoing regrouping of import statements, making sure messages we use when wrapping errors match the diagnostics that we're logging.

@rhatdan
Copy link
Member

rhatdan commented Jul 11, 2017

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants