summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Goff <cpuguy83@gmail.com>2017-04-11 09:56:36 -0400
committerVictor Vieux <victorvieux@gmail.com>2017-04-25 16:40:22 -0700
commit2d8ebec4a8bc9d8dcafb932064708a5893786902 (patch)
treec6abb80d6e959236b5e59aacaa06f6187d113a1f
parentde8fbb4812a9ab4e6195606574458e29225d3048 (diff)
downloaddocker-2d8ebec4a8bc9d8dcafb932064708a5893786902.tar.gz
Make sure plugin rootfs is unmounted on upgraded
In some cases, if a user specifies `-f` when disabling a plugin mounts can still exist on the plugin rootfs. This can cause problems during upgrade where the rootfs is removed and may cause data loss. To resolve this, ensure the rootfs is unmounted before performing an upgrade. Signed-off-by: Brian Goff <cpuguy83@gmail.com> (cherry picked from commit 83f44d232d2c5d7ce7c5e10d2cd0f912d32c2ea5) Signed-off-by: Victor Vieux <victorvieux@gmail.com>
-rw-r--r--plugin/backend_linux.go2
-rw-r--r--plugin/manager_linux.go10
2 files changed, 10 insertions, 2 deletions
diff --git a/plugin/backend_linux.go b/plugin/backend_linux.go
index 8153727860..1f01dab6a7 100644
--- a/plugin/backend_linux.go
+++ b/plugin/backend_linux.go
@@ -648,7 +648,7 @@ func (pm *Manager) Remove(name string, config *types.PluginRmConfig) error {
func getMounts(root string) ([]string, error) {
infos, err := mount.GetMounts()
if err != nil {
- return nil, errors.Wrap(err, "failed to read mount table while performing recursive unmount")
+ return nil, errors.Wrap(err, "failed to read mount table")
}
var mounts []string
diff --git a/plugin/manager_linux.go b/plugin/manager_linux.go
index b8638dfe7d..80fc041623 100644
--- a/plugin/manager_linux.go
+++ b/plugin/manager_linux.go
@@ -199,9 +199,17 @@ func (pm *Manager) upgradePlugin(p *v2.Plugin, configDigest digest.Digest, blobs
pdir := filepath.Join(pm.config.Root, p.PluginObj.ID)
orig := filepath.Join(pdir, "rootfs")
+
+ // Make sure nothing is mounted
+ // This could happen if the plugin was disabled with `-f` with active mounts.
+ // If there is anything in `orig` is still mounted, this should error out.
+ if err := recursiveUnmount(orig); err != nil {
+ return err
+ }
+
backup := orig + "-old"
if err := os.Rename(orig, backup); err != nil {
- return err
+ return errors.Wrap(err, "error backing up plugin data before upgrade")
}
defer func() {