[lxc-devel] [lxd/master] Storage: Adds EnsureMountPath calls after mounting volumes in generic functions
tomponline on Github
lxc-bot at linuxcontainers.org
Sat Jan 11 17:43:15 UTC 2020
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 637 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200111/52607dc3/attachment.bin>
-------------- next part --------------
From 44a21da2e38ff7f01d89feabc81f848a8e1c2841 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Sat, 11 Jan 2020 16:36:47 +0000
Subject: [PATCH] lxd/storage/drivers/generic: Adds EnsureMount path calls
after mounting volumes
Ensures that permissions set correctly after mounting and any syncing/unpacking/copying process.
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
lxd/storage/drivers/generic.go | 28 +++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/lxd/storage/drivers/generic.go b/lxd/storage/drivers/generic.go
index f1bac2babf..56df274740 100644
--- a/lxd/storage/drivers/generic.go
+++ b/lxd/storage/drivers/generic.go
@@ -77,10 +77,22 @@ func genericCopyVolume(d Driver, initVolume func(vol Volume) (func(), error), vo
}
// Copy source to destination (mounting each volume if needed).
- return srcVol.MountTask(func(srcMountPath string, op *operations.Operation) error {
+ err := srcVol.MountTask(func(srcMountPath string, op *operations.Operation) error {
_, err := rsync.LocalCopy(srcMountPath, mountPath, bwlimit, true)
return err
}, op)
+ if err != nil {
+ return err
+ }
+
+ // Run EnsureMountPath after mounting and copying to ensure the mounted directory has the
+ // correct permissions set.
+ err = vol.EnsureMountPath()
+ if err != nil {
+ return err
+ }
+
+ return nil
}, op)
if err != nil {
return err
@@ -172,6 +184,13 @@ func genericCreateVolumeFromMigration(d Driver, initVolume func(vol Volume) (fun
}
}
+ // Run EnsureMountPath after mounting and syncing to ensure the mounted directory has the
+ // correct permissions set.
+ err = vol.EnsureMountPath()
+ if err != nil {
+ return err
+ }
+
return nil
}, op)
if err != nil {
@@ -285,6 +304,13 @@ func genericBackupUnpack(d Driver, vol Volume, snapshots []string, srcData io.Re
return nil, nil, err
}
+ // Run EnsureMountPath after mounting and unpacking to ensure the mounted directory has the
+ // correct permissions set.
+ err = vol.EnsureMountPath()
+ if err != nil {
+ return nil, nil, err
+ }
+
revertExternal := revert.Clone() // Clone before calling revert.Success() so we can return the Fail func.
revert.Success()
return postHook, revertExternal.Fail, nil
More information about the lxc-devel
mailing list