Browse code

Allow graphdriver plugins to use v2

Currently the plugin initialization is too late for a loaded v2 plugin
to be usable as a graph driver.

This moves the initialization up before we create the graph driver.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>

Brian Goff authored on 2016/11/19 06:54:11
Showing 2 changed files
... ...
@@ -550,7 +550,12 @@ func NewDaemon(config *Config, registryService registry.Service, containerdRemot
550 550
 		driverName = config.GraphDriver
551 551
 	}
552 552
 
553
+	d.RegistryService = registryService
553 554
 	d.PluginStore = pluginstore.NewStore(config.Root)
555
+	// Plugin system initialization should happen before restore. Do not change order.
556
+	if err := d.pluginInit(config, containerdRemote); err != nil {
557
+		return nil, err
558
+	}
554 559
 
555 560
 	d.layerStore, err = layer.NewStoreFromOptions(layer.StoreOptions{
556 561
 		StorePath:                 config.Root,
... ...
@@ -649,7 +654,6 @@ func NewDaemon(config *Config, registryService registry.Service, containerdRemot
649 649
 		Type:   config.LogConfig.Type,
650 650
 		Config: config.LogConfig.Config,
651 651
 	}
652
-	d.RegistryService = registryService
653 652
 	d.EventsService = eventsService
654 653
 	d.volumes = volStore
655 654
 	d.root = config.Root
... ...
@@ -668,11 +672,6 @@ func NewDaemon(config *Config, registryService registry.Service, containerdRemot
668 668
 		return nil, err
669 669
 	}
670 670
 
671
-	// Plugin system initialization should happen before restore. Do not change order.
672
-	if err := d.pluginInit(config, containerdRemote); err != nil {
673
-		return nil, err
674
-	}
675
-
676 671
 	if err := d.restore(); err != nil {
677 672
 		return nil, err
678 673
 	}
... ...
@@ -3,6 +3,7 @@ package graphdriver
3 3
 import (
4 4
 	"fmt"
5 5
 	"io"
6
+	"path/filepath"
6 7
 
7 8
 	"github.com/docker/docker/pkg/plugingetter"
8 9
 )
... ...
@@ -26,5 +27,5 @@ func lookupPlugin(name, home string, opts []string, pg plugingetter.PluginGetter
26 26
 
27 27
 func newPluginDriver(name, home string, opts []string, c pluginClient) (Driver, error) {
28 28
 	proxy := &graphDriverProxy{name, c}
29
-	return proxy, proxy.Init(home, opts)
29
+	return proxy, proxy.Init(filepath.Join(home, name), opts)
30 30
 }