[lxc-devel] [lxd/master] Fix copying of containers within project on CEPH
stgraber on Github
lxc-bot at linuxcontainers.org
Wed Nov 14 23:54:59 UTC 2018
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 301 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20181114/a5ad5c5c/attachment.bin>
-------------- next part --------------
From fe0fa4b39766d489a70dc9dee00b8bf5dc209be9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 14 Nov 2018 11:45:08 -0800
Subject: [PATCH 1/2] lxd/storage/ceph: Fix copies within project
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
lxd/storage_ceph.go | 31 +++++++++++++------------------
lxd/storage_ceph_utils.go | 21 ++++++++-------------
2 files changed, 21 insertions(+), 31 deletions(-)
diff --git a/lxd/storage_ceph.go b/lxd/storage_ceph.go
index dd2fac185c..2e79ba5e11 100644
--- a/lxd/storage_ceph.go
+++ b/lxd/storage_ceph.go
@@ -1146,8 +1146,7 @@ func (s *storageCeph) doCrossPoolContainerCopy(target container, source containe
func (s *storageCeph) ContainerCopy(target container, source container,
containerOnly bool) error {
sourceContainerName := source.Name()
- logger.Debugf(`Copying RBD container storage %s to %s`,
- sourceContainerName, target.Name())
+ logger.Debugf(`Copying RBD container storage %s to %s`, sourceContainerName, target.Name())
revert := true
@@ -1177,8 +1176,7 @@ func (s *storageCeph) ContainerCopy(target container, source container,
sourceContainerName)
targetContainerName := target.Name()
- targetContainerMountPoint := getContainerMountPoint(target.Project(), s.pool.Name,
- targetContainerName)
+ targetContainerMountPoint := getContainerMountPoint(target.Project(), s.pool.Name, targetContainerName)
if containerOnly || len(snapshots) == 0 {
if s.pool.Config["ceph.rbd.clone_copy"] != "" &&
!shared.IsTrue(s.pool.Config["ceph.rbd.clone_copy"]) {
@@ -1230,7 +1228,7 @@ func (s *storageCeph) ContainerCopy(target container, source container,
// create empty dummy volume
err = cephRBDVolumeCreate(s.ClusterName, s.OSDPoolName,
- targetContainerName, storagePoolVolumeTypeNameContainer,
+ projectPrefix(target.Project(), targetContainerName), storagePoolVolumeTypeNameContainer,
"0", s.UserName)
if err != nil {
logger.Errorf(`Failed to create RBD storage volume "%s" on storage pool "%s": %s`, targetContainerName, s.pool.Name, err)
@@ -1245,7 +1243,7 @@ func (s *storageCeph) ContainerCopy(target container, source container,
}
err := cephRBDVolumeDelete(s.ClusterName, s.OSDPoolName,
- targetContainerName,
+ projectPrefix(target.Project(), targetContainerName),
storagePoolVolumeTypeNameContainer, s.UserName)
if err != nil {
logger.Warnf(`Failed to delete RBD storage volume "%s" on storage pool "%s": %s`, targetContainerName, s.pool.Name, err)
@@ -1256,7 +1254,7 @@ func (s *storageCeph) ContainerCopy(target container, source container,
targetVolumeName := fmt.Sprintf(
"%s/container_%s",
s.OSDPoolName,
- targetContainerName)
+ projectPrefix(target.Project(), targetContainerName))
lastSnap := ""
for i, snap := range snapshots {
@@ -1271,7 +1269,7 @@ func (s *storageCeph) ContainerCopy(target container, source container,
sourceVolumeName := fmt.Sprintf(
"%s/container_%s at snapshot_%s",
s.OSDPoolName,
- sourceContainerName,
+ projectPrefix(source.Project(), sourceContainerName),
snapOnlyName)
err = s.copyWithSnapshots(
@@ -1292,7 +1290,7 @@ func (s *storageCeph) ContainerCopy(target container, source container,
}
err := cephRBDSnapshotDelete(s.ClusterName,
- s.OSDPoolName, targetContainerName,
+ s.OSDPoolName, projectPrefix(target.Project(), targetContainerName),
storagePoolVolumeTypeNameContainer,
snapOnlyName, s.UserName)
if err != nil {
@@ -1301,9 +1299,7 @@ func (s *storageCeph) ContainerCopy(target container, source container,
}()
// create snapshot mountpoint
- newTargetName := fmt.Sprintf("%s/%s",
- targetContainerName, snapOnlyName)
-
+ newTargetName := fmt.Sprintf("%s/%s", targetContainerName, snapOnlyName)
containersPath := getSnapshotMountPoint(
target.Project(),
s.pool.Name,
@@ -1348,7 +1344,7 @@ func (s *storageCeph) ContainerCopy(target container, source container,
sourceVolumeName := fmt.Sprintf(
"%s/container_%s",
s.OSDPoolName,
- sourceContainerName)
+ projectPrefix(source.Project(), sourceContainerName))
err = s.copyWithSnapshots(
sourceVolumeName,
targetVolumeName,
@@ -1365,7 +1361,7 @@ func (s *storageCeph) ContainerCopy(target container, source container,
// map the container's volume
_, err = cephRBDVolumeMap(s.ClusterName, s.OSDPoolName,
- targetContainerName, storagePoolVolumeTypeNameContainer,
+ projectPrefix(target.Project(), targetContainerName), storagePoolVolumeTypeNameContainer,
s.UserName)
if err != nil {
logger.Errorf(`Failed to map RBD storage volume for container "%s" on storage pool "%s": %s`, targetContainerName, s.pool.Name, err)
@@ -1696,7 +1692,6 @@ func (s *storageCeph) ContainerSnapshotDelete(snapshotContainer container) error
snapshotContainerName := snapshotContainer.Name()
sourceContainerName, sourceContainerSnapOnlyName, _ :=
containerGetParentAndSnapshotName(snapshotContainerName)
- sourceContainerSnapOnlyName = projectPrefix(snapshotContainer.Project(), sourceContainerSnapOnlyName)
snapshotName := fmt.Sprintf("snapshot_%s", sourceContainerSnapOnlyName)
rbdVolumeExists := cephRBDSnapshotExists(s.ClusterName, s.OSDPoolName,
@@ -1765,9 +1760,9 @@ func (s *storageCeph) ContainerSnapshotRename(c container, newName string) error
containerOnlyName, snapOnlyName, _ := containerGetParentAndSnapshotName(oldName)
containerOnlyName = projectPrefix(c.Project(), containerOnlyName)
- oldSnapOnlyName := fmt.Sprintf("snapshot_%s", projectPrefix(c.Project(), snapOnlyName))
+ oldSnapOnlyName := fmt.Sprintf("snapshot_%s", snapOnlyName)
_, newSnapOnlyName, _ := containerGetParentAndSnapshotName(newName)
- newSnapOnlyName = fmt.Sprintf("snapshot_%s", projectPrefix(c.Project(), newSnapOnlyName))
+ newSnapOnlyName = fmt.Sprintf("snapshot_%s", newSnapOnlyName)
err := cephRBDVolumeSnapshotRename(s.ClusterName, s.OSDPoolName,
containerOnlyName, storagePoolVolumeTypeNameContainer, oldSnapOnlyName,
newSnapOnlyName, s.UserName)
@@ -1815,7 +1810,7 @@ func (s *storageCeph) ContainerSnapshotStart(c container) (bool, error) {
containerOnlyName = projectPrefix(c.Project(), containerOnlyName)
// protect
- prefixedSnapOnlyName := fmt.Sprintf("snapshot_%s", projectPrefix(c.Project(), snapOnlyName))
+ prefixedSnapOnlyName := fmt.Sprintf("snapshot_%s", snapOnlyName)
err := cephRBDSnapshotProtect(s.ClusterName, s.OSDPoolName,
containerOnlyName, storagePoolVolumeTypeNameContainer,
prefixedSnapOnlyName, s.UserName)
diff --git a/lxd/storage_ceph_utils.go b/lxd/storage_ceph_utils.go
index fba0d4f18d..a8f9a84b89 100644
--- a/lxd/storage_ceph_utils.go
+++ b/lxd/storage_ceph_utils.go
@@ -707,8 +707,8 @@ func (s *storageCeph) copyWithoutSnapshotsFull(target container,
logger.Debugf(`Creating non-sparse copy of RBD storage volume for container "%s" to "%s" without snapshots`, source.Name(), target.Name())
sourceIsSnapshot := source.IsSnapshot()
- sourceContainerName := source.Name()
- targetContainerName := target.Name()
+ sourceContainerName := projectPrefix(source.Project(), source.Name())
+ targetContainerName := projectPrefix(target.Project(), target.Name())
oldVolumeName := fmt.Sprintf("%s/container_%s", s.OSDPoolName,
sourceContainerName)
newVolumeName := fmt.Sprintf("%s/container_%s", s.OSDPoolName,
@@ -735,10 +735,8 @@ func (s *storageCeph) copyWithoutSnapshotsFull(target container,
return err
}
- targetContainerMountPoint := getContainerMountPoint(target.Project(), s.pool.Name,
- target.Name())
- err = createContainerMountpoint(targetContainerMountPoint, target.Path(),
- target.IsPrivileged())
+ targetContainerMountPoint := getContainerMountPoint(target.Project(), s.pool.Name, target.Name())
+ err = createContainerMountpoint(targetContainerMountPoint, target.Path(), target.IsPrivileged())
if err != nil {
return err
}
@@ -772,8 +770,8 @@ func (s *storageCeph) copyWithoutSnapshotsSparse(target container,
target.Name())
sourceIsSnapshot := source.IsSnapshot()
- sourceContainerName := source.Name()
- targetContainerName := target.Name()
+ sourceContainerName := projectPrefix(source.Project(), source.Name())
+ targetContainerName := projectPrefix(target.Project(), target.Name())
sourceContainerOnlyName := sourceContainerName
sourceSnapshotOnlyName := ""
snapshotName := fmt.Sprintf("zombie_snapshot_%s",
@@ -828,10 +826,8 @@ func (s *storageCeph) copyWithoutSnapshotsSparse(target container,
return err
}
- targetContainerMountPoint := getContainerMountPoint(target.Project(), s.pool.Name,
- target.Name())
- err = createContainerMountpoint(targetContainerMountPoint,
- target.Path(), target.IsPrivileged())
+ targetContainerMountPoint := getContainerMountPoint(target.Project(), s.pool.Name, target.Name())
+ err = createContainerMountpoint(targetContainerMountPoint, target.Path(), target.IsPrivileged())
if err != nil {
return err
}
@@ -1860,7 +1856,6 @@ func (s *storageCeph) doContainerSnapshotCreate(project, targetName string, sour
revert := true
_, targetSnapshotOnlyName, _ := containerGetParentAndSnapshotName(targetName)
- targetSnapshotOnlyName = projectPrefix(project, targetSnapshotOnlyName)
targetSnapshotName := fmt.Sprintf("snapshot_%s", targetSnapshotOnlyName)
err := cephRBDSnapshotCreate(s.ClusterName, s.OSDPoolName,
projectPrefix(project, sourceName), storagePoolVolumeTypeNameContainer,
From efa9493704a2ec0ffcec69fc095b5afebac2335a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 14 Nov 2018 15:38:36 -0800
Subject: [PATCH 2/2] lxd/networks: Fix projects in dnsmasq.hosts
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
lxd/networks_utils.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lxd/networks_utils.go b/lxd/networks_utils.go
index a0802b7d86..480318c252 100644
--- a/lxd/networks_utils.go
+++ b/lxd/networks_utils.go
@@ -849,7 +849,7 @@ func networkUpdateStatic(s *state.State, networkName string) error {
entries[d["parent"]] = [][]string{}
}
- entries[d["parent"]] = append(entries[d["parent"]], []string{d["hwaddr"], c.Name(), d["ipv4.address"], d["ipv6.address"]})
+ entries[d["parent"]] = append(entries[d["parent"]], []string{d["hwaddr"], projectPrefix(c.Project(), c.Name()), d["ipv4.address"], d["ipv6.address"]})
}
}
More information about the lxc-devel
mailing list