Add ErrPrerequisites to improve misleading errors
There are two cases where we can't use a graphdriver: 1) the graphdriver itself isn't supported by the system 2) the graphdriver is supported by some configuration/prerequisites are missing This introduces a new error for the 2) case and uses it when trying to run docker with btrfs backend on a non-btrfs filesystem. Docker-DCO-1.1-Signed-off-by: Johannes 'fish' Ziemke <github@freigeist.org> (github: discordianfish)
This commit is contained in:
parent
8622641b58
commit
75754e69f6
3 changed files with 11 additions and 6 deletions
|
@ -18,6 +18,10 @@ import (
|
|||
"unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
btrfsSuperMagic = 0x9123683E
|
||||
)
|
||||
|
||||
func init() {
|
||||
graphdriver.Register("btrfs", Init)
|
||||
}
|
||||
|
@ -30,8 +34,8 @@ func Init(home string) (graphdriver.Driver, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if buf.Type != 0x9123683E {
|
||||
return nil, graphdriver.ErrNotSupported
|
||||
if buf.Type != btrfsSuperMagic {
|
||||
return nil, graphdriver.ErrPrerequisites
|
||||
}
|
||||
|
||||
return &Driver{
|
||||
|
|
|
@ -44,7 +44,8 @@ var (
|
|||
"vfs",
|
||||
}
|
||||
|
||||
ErrNotSupported = errors.New("driver not supported")
|
||||
ErrNotSupported = errors.New("driver not supported")
|
||||
ErrPrerequisites = errors.New("Prerequisites for driver not satisfied (wrong filesystem?)")
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -78,7 +79,7 @@ func New(root string) (driver Driver, err error) {
|
|||
for _, name := range priority {
|
||||
driver, err = GetDriver(name, root)
|
||||
if err != nil {
|
||||
if err == ErrNotSupported {
|
||||
if err == ErrNotSupported || err == ErrPrerequisites {
|
||||
continue
|
||||
}
|
||||
return nil, err
|
||||
|
@ -89,7 +90,7 @@ func New(root string) (driver Driver, err error) {
|
|||
// Check all registered drivers if no priority driver is found
|
||||
for _, initFunc := range drivers {
|
||||
if driver, err = initFunc(root); err != nil {
|
||||
if err == ErrNotSupported {
|
||||
if err == ErrNotSupported || err == ErrPrerequisites {
|
||||
continue
|
||||
}
|
||||
return nil, err
|
||||
|
|
|
@ -31,7 +31,7 @@ func newDriver(t *testing.T, name string) *Driver {
|
|||
|
||||
d, err := graphdriver.GetDriver(name, root)
|
||||
if err != nil {
|
||||
if err == graphdriver.ErrNotSupported {
|
||||
if err == graphdriver.ErrNotSupported || err == graphdriver.ErrPrerequisites {
|
||||
t.Skip("Driver %s not supported", name)
|
||||
}
|
||||
t.Fatal(err)
|
||||
|
|
Loading…
Reference in a new issue