瀏覽代碼

plugins: remove automatic mounting of a state dir

Signed-off-by: Tibor Vass <tibor@docker.com>
Tibor Vass 9 年之前
父節點
當前提交
15ff9de658
共有 2 個文件被更改,包括 6 次插入14 次删除
  1. 1 8
      plugin/manager.go
  2. 5 6
      plugin/manager_linux.go

+ 1 - 8
plugin/manager.go

@@ -22,10 +22,7 @@ import (
 	"github.com/docker/engine-api/types"
 )
 
-const (
-	defaultPluginRuntimeDestination = "/run/docker/plugins"
-	defaultPluginStateDestination   = "/state"
-)
+const defaultPluginRuntimeDestination = "/run/docker/plugins"
 
 var manager *Manager
 
@@ -49,7 +46,6 @@ type plugin struct {
 	P                 types.Plugin `json:"plugin"`
 	client            *plugins.Client
 	restartManager    restartmanager.RestartManager
-	stateSourcePath   string
 	runtimeSourcePath string
 }
 
@@ -72,7 +68,6 @@ func (pm *Manager) newPlugin(ref reference.Named, id string) *plugin {
 			Name: ref.Name(),
 			ID:   id,
 		},
-		stateSourcePath:   filepath.Join(pm.libRoot, id, "state"),
 		runtimeSourcePath: filepath.Join(pm.runRoot, id),
 	}
 	if ref, ok := ref.(reference.NamedTagged); ok {
@@ -82,7 +77,6 @@ func (pm *Manager) newPlugin(ref reference.Named, id string) *plugin {
 }
 
 func (pm *Manager) restorePlugin(p *plugin) error {
-	p.stateSourcePath = filepath.Join(pm.libRoot, p.P.ID, "state")
 	p.runtimeSourcePath = filepath.Join(pm.runRoot, p.P.ID)
 	if p.P.Active {
 		return pm.restore(p)
@@ -342,7 +336,6 @@ func (pm *Manager) remove(p *plugin) error {
 	}
 	pm.Lock() // fixme: lock single record
 	defer pm.Unlock()
-	os.RemoveAll(p.stateSourcePath)
 	delete(pm.plugins, p.P.ID)
 	delete(pm.nameToID, p.Name())
 	pm.save()

+ 5 - 6
plugin/manager_linux.go

@@ -70,11 +70,6 @@ func (pm *Manager) initSpec(p *plugin) (*specs.Spec, error) {
 		Destination: defaultPluginRuntimeDestination,
 		Type:        "bind",
 		Options:     []string{"rbind", "rshared"},
-	}, types.PluginMount{
-		Source:      &p.stateSourcePath,
-		Destination: defaultPluginStateDestination,
-		Type:        "bind",
-		Options:     []string{"rbind", "rshared"},
 	})
 	for _, mount := range mounts {
 		m := specs.Mount{
@@ -105,10 +100,14 @@ func (pm *Manager) initSpec(p *plugin) (*specs.Spec, error) {
 	envs = append(envs, p.P.Config.Env...)
 
 	args := append(p.P.Manifest.Entrypoint, p.P.Config.Args...)
+	cwd := p.P.Manifest.Workdir
+	if len(cwd) == 0 {
+		cwd = "/"
+	}
 	s.Process = specs.Process{
 		Terminal: false,
 		Args:     args,
-		Cwd:      "/", // TODO: add in manifest?
+		Cwd:      cwd,
 		Env:      envs,
 	}