From 3b16cb15b496edc3dc080560c7189e06e19c5343 Mon Sep 17 00:00:00 2001 From: Brian Goff Date: Thu, 8 Oct 2015 21:29:20 -0400 Subject: [PATCH] Do not probe plugins for graph init unless `-s` When `-s` is not specified, there is no need to ask if there is a plugin with the specified name. This speeds up unit tests dramatically since they don't need to wait the timeout period for each call to `graphdriver.New`. Signed-off-by: Brian Goff --- daemon/graphdriver/driver.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/daemon/graphdriver/driver.go b/daemon/graphdriver/driver.go index a05d1c7bc3..bd739ce329 100644 --- a/daemon/graphdriver/driver.go +++ b/daemon/graphdriver/driver.go @@ -118,6 +118,15 @@ func GetDriver(name, home string, options []string) (Driver, error) { return nil, ErrNotSupported } +// getBuiltinDriver initalizes and returns the registered driver, but does not try to load from plugins +func getBuiltinDriver(name, home string, options []string) (Driver, error) { + if initFunc, exists := drivers[name]; exists { + return initFunc(filepath.Join(home, name), options) + } + logrus.Errorf("Failed to built-in GetDriver graph %s %s", name, home) + return nil, ErrNotSupported +} + // New creates the driver and initializes it at the specified root. func New(root string, options []string) (driver Driver, err error) { for _, name := range []string{os.Getenv("DOCKER_DRIVER"), DefaultDriver} { @@ -138,7 +147,7 @@ func New(root string, options []string) (driver Driver, err error) { // of the state found from prior drivers, check in order of our priority // which we would prefer if prior == name { - driver, err = GetDriver(name, root, options) + driver, err = getBuiltinDriver(name, root, options) if err != nil { // unlike below, we will return error here, because there is prior // state, and now it is no longer supported/prereq/compatible, so @@ -158,7 +167,7 @@ func New(root string, options []string) (driver Driver, err error) { // Check for priority drivers first for _, name := range priority { - driver, err = GetDriver(name, root, options) + driver, err = getBuiltinDriver(name, root, options) if err != nil { if err == ErrNotSupported || err == ErrPrerequisites || err == ErrIncompatibleFS { continue