From e6f784e3df2095366fd99fd42ab5a2d0b451bd07 Mon Sep 17 00:00:00 2001 From: Brian Goff Date: Mon, 18 Dec 2017 21:28:16 -0500 Subject: [PATCH] Make sure plugin mounts are cleaned up Signed-off-by: Brian Goff --- plugin/manager.go | 5 +++++ plugin/manager_linux.go | 3 +++ 2 files changed, 8 insertions(+) diff --git a/plugin/manager.go b/plugin/manager.go index 2bdf82e56f..750e3a5349 100644 --- a/plugin/manager.go +++ b/plugin/manager.go @@ -19,6 +19,7 @@ import ( "github.com/docker/docker/layer" "github.com/docker/docker/pkg/authorization" "github.com/docker/docker/pkg/ioutils" + "github.com/docker/docker/pkg/mount" "github.com/docker/docker/pkg/pubsub" "github.com/docker/docker/pkg/system" "github.com/docker/docker/plugin/v2" @@ -155,6 +156,10 @@ func (pm *Manager) HandleExitEvent(id string) error { if restart { pm.enable(p, c, true) + } else { + if err := mount.RecursiveUnmount(filepath.Join(pm.config.Root, id)); err != nil { + return errors.Wrap(err, "error cleaning up plugin mounts") + } } return nil } diff --git a/plugin/manager_linux.go b/plugin/manager_linux.go index 1def28c2a0..a98702802f 100644 --- a/plugin/manager_linux.go +++ b/plugin/manager_linux.go @@ -187,6 +187,9 @@ func (pm *Manager) Shutdown() { shutdownPlugin(p, c, pm.executor) } } + if err := mount.RecursiveUnmount(pm.config.Root); err != nil { + logrus.WithError(err).Warn("error cleaning up plugin mounts") + } } func (pm *Manager) upgradePlugin(p *v2.Plugin, configDigest digest.Digest, blobsums []digest.Digest, tmpRootFSDir string, privileges *types.PluginPrivileges) (err error) {