Browse code

plugins: remove automatic mounting of a state dir

Signed-off-by: Tibor Vass <tibor@docker.com>

Tibor Vass authored on 2016/06/18 01:13:35
Showing 2 changed files
... ...
@@ -22,10 +22,7 @@ import (
22 22
 	"github.com/docker/engine-api/types"
23 23
 )
24 24
 
25
-const (
26
-	defaultPluginRuntimeDestination = "/run/docker/plugins"
27
-	defaultPluginStateDestination   = "/state"
28
-)
25
+const defaultPluginRuntimeDestination = "/run/docker/plugins"
29 26
 
30 27
 var manager *Manager
31 28
 
... ...
@@ -49,7 +46,6 @@ type plugin struct {
49 49
 	P                 types.Plugin `json:"plugin"`
50 50
 	client            *plugins.Client
51 51
 	restartManager    restartmanager.RestartManager
52
-	stateSourcePath   string
53 52
 	runtimeSourcePath string
54 53
 }
55 54
 
... ...
@@ -72,7 +68,6 @@ func (pm *Manager) newPlugin(ref reference.Named, id string) *plugin {
72 72
 			Name: ref.Name(),
73 73
 			ID:   id,
74 74
 		},
75
-		stateSourcePath:   filepath.Join(pm.libRoot, id, "state"),
76 75
 		runtimeSourcePath: filepath.Join(pm.runRoot, id),
77 76
 	}
78 77
 	if ref, ok := ref.(reference.NamedTagged); ok {
... ...
@@ -82,7 +77,6 @@ func (pm *Manager) newPlugin(ref reference.Named, id string) *plugin {
82 82
 }
83 83
 
84 84
 func (pm *Manager) restorePlugin(p *plugin) error {
85
-	p.stateSourcePath = filepath.Join(pm.libRoot, p.P.ID, "state")
86 85
 	p.runtimeSourcePath = filepath.Join(pm.runRoot, p.P.ID)
87 86
 	if p.P.Active {
88 87
 		return pm.restore(p)
... ...
@@ -342,7 +336,6 @@ func (pm *Manager) remove(p *plugin) error {
342 342
 	}
343 343
 	pm.Lock() // fixme: lock single record
344 344
 	defer pm.Unlock()
345
-	os.RemoveAll(p.stateSourcePath)
346 345
 	delete(pm.plugins, p.P.ID)
347 346
 	delete(pm.nameToID, p.Name())
348 347
 	pm.save()
... ...
@@ -70,11 +70,6 @@ func (pm *Manager) initSpec(p *plugin) (*specs.Spec, error) {
70 70
 		Destination: defaultPluginRuntimeDestination,
71 71
 		Type:        "bind",
72 72
 		Options:     []string{"rbind", "rshared"},
73
-	}, types.PluginMount{
74
-		Source:      &p.stateSourcePath,
75
-		Destination: defaultPluginStateDestination,
76
-		Type:        "bind",
77
-		Options:     []string{"rbind", "rshared"},
78 73
 	})
79 74
 	for _, mount := range mounts {
80 75
 		m := specs.Mount{
... ...
@@ -105,10 +100,14 @@ func (pm *Manager) initSpec(p *plugin) (*specs.Spec, error) {
105 105
 	envs = append(envs, p.P.Config.Env...)
106 106
 
107 107
 	args := append(p.P.Manifest.Entrypoint, p.P.Config.Args...)
108
+	cwd := p.P.Manifest.Workdir
109
+	if len(cwd) == 0 {
110
+		cwd = "/"
111
+	}
108 112
 	s.Process = specs.Process{
109 113
 		Terminal: false,
110 114
 		Args:     args,
111
-		Cwd:      "/", // TODO: add in manifest?
115
+		Cwd:      cwd,
112 116
 		Env:      envs,
113 117
 	}
114 118