mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
graphdriver: Fail initialization if supported but got error
If a graphdriver fails initialization due to ErrNotSupported we ignore that and keep trying the next. But if some driver has a different error (for instance if you specified an unknown option for it) we fail the daemon startup, printing the error, rather than falling back to an unexected driver (typically vfs) which may not match what you have run earlier. Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
This commit is contained in:
parent
27744062aa
commit
4bdb8c03fc
4 changed files with 18 additions and 10 deletions
|
@ -54,7 +54,7 @@ type Driver struct {
|
||||||
func Init(root string) (graphdriver.Driver, error) {
|
func Init(root string) (graphdriver.Driver, error) {
|
||||||
// Try to load the aufs kernel module
|
// Try to load the aufs kernel module
|
||||||
if err := supportsAufs(); err != nil {
|
if err := supportsAufs(); err != nil {
|
||||||
return nil, err
|
return nil, graphdriver.ErrNotSupported
|
||||||
}
|
}
|
||||||
paths := []string{
|
paths := []string{
|
||||||
"mnt",
|
"mnt",
|
||||||
|
|
|
@ -19,7 +19,7 @@ var (
|
||||||
func testInit(dir string, t *testing.T) graphdriver.Driver {
|
func testInit(dir string, t *testing.T) graphdriver.Driver {
|
||||||
d, err := Init(dir)
|
d, err := Init(dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == ErrAufsNotSupported {
|
if err == graphdriver.ErrNotSupported {
|
||||||
t.Skip(err)
|
t.Skip(err)
|
||||||
} else {
|
} else {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
|
|
@ -31,7 +31,7 @@ func Init(home string) (graphdriver.Driver, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if buf.Type != 0x9123683E {
|
if buf.Type != 0x9123683E {
|
||||||
return nil, fmt.Errorf("%s is not a btrfs filesystem", rootdir)
|
return nil, graphdriver.ErrNotSupported
|
||||||
}
|
}
|
||||||
|
|
||||||
return &Driver{
|
return &Driver{
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package graphdriver
|
package graphdriver
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/dotcloud/docker/archive"
|
"github.com/dotcloud/docker/archive"
|
||||||
"github.com/dotcloud/docker/utils"
|
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
)
|
)
|
||||||
|
@ -43,6 +43,8 @@ var (
|
||||||
"devicemapper",
|
"devicemapper",
|
||||||
"vfs",
|
"vfs",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ErrNotSupported = errors.New("driver not supported")
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -62,7 +64,7 @@ func GetDriver(name, home string) (Driver, error) {
|
||||||
if initFunc, exists := drivers[name]; exists {
|
if initFunc, exists := drivers[name]; exists {
|
||||||
return initFunc(path.Join(home, name))
|
return initFunc(path.Join(home, name))
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("No such driver: %s", name)
|
return nil, ErrNotSupported
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(root string) (driver Driver, err error) {
|
func New(root string) (driver Driver, err error) {
|
||||||
|
@ -74,9 +76,12 @@ func New(root string) (driver Driver, err error) {
|
||||||
|
|
||||||
// Check for priority drivers first
|
// Check for priority drivers first
|
||||||
for _, name := range priority {
|
for _, name := range priority {
|
||||||
if driver, err = GetDriver(name, root); err != nil {
|
driver, err = GetDriver(name, root)
|
||||||
utils.Debugf("Error loading driver %s: %s", name, err)
|
if err != nil {
|
||||||
continue
|
if err == ErrNotSupported {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
return driver, nil
|
return driver, nil
|
||||||
}
|
}
|
||||||
|
@ -84,9 +89,12 @@ func New(root string) (driver Driver, err error) {
|
||||||
// Check all registered drivers if no priority driver is found
|
// Check all registered drivers if no priority driver is found
|
||||||
for _, initFunc := range drivers {
|
for _, initFunc := range drivers {
|
||||||
if driver, err = initFunc(root); err != nil {
|
if driver, err = initFunc(root); err != nil {
|
||||||
continue
|
if err == ErrNotSupported {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
return driver, nil
|
return driver, nil
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, fmt.Errorf("No supported storage backend found")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue