stgraber on Github
2018-11-30 18:29:50 UTC
From c23afbd10b7c3c1b987b38ca97af4f83318c2350 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <***@ubuntu.com>
Date: Fri, 30 Nov 2018 13:29:13 -0500
Subject: [PATCH] lxd/storage/lvm: Fix project handling
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <***@ubuntu.com>
---
lxd/storage_lvm.go | 16 ++++++++--------
lxd/storage_lvm_utils.go | 4 ++--
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/lxd/storage_lvm.go b/lxd/storage_lvm.go
index 5377c0a49b..3745dff293 100644
--- a/lxd/storage_lvm.go
+++ b/lxd/storage_lvm.go
@@ -919,7 +919,7 @@ func (s *storageLvm) StoragePoolVolumeRename(newName string) error {
}
func (s *storageLvm) ContainerStorageReady(container container) bool {
- containerLvmName := containerNameToLVName(container.Name())
+ containerLvmName := containerNameToLVName(projectPrefix(container.Project(), container.Name()))
poolName := s.getOnDiskPoolName()
containerLvmPath := getLvmDevPath(container.Project(), poolName, storagePoolVolumeAPIEndpointContainers, containerLvmName)
ok, _ := storageLVExists(containerLvmPath)
@@ -932,7 +932,7 @@ func (s *storageLvm) ContainerCreate(container container) error {
tryUndo := true
containerName := container.Name()
- containerLvmName := containerNameToLVName(containerName)
+ containerLvmName := containerNameToLVName(projectPrefix(container.Project(), containerName))
thinPoolName := s.getLvmThinpoolName()
lvFsType := s.getLvmFilesystem()
lvSize, err := s.getLvmVolumeSize()
@@ -996,7 +996,7 @@ func (s *storageLvm) ContainerCreateFromImage(container container, fingerprint s
tryUndo := true
containerName := container.Name()
- containerLvmName := containerNameToLVName(containerName)
+ containerLvmName := containerNameToLVName(projectPrefix(container.Project(), containerName))
var err error
if s.useThinpool {
@@ -1078,7 +1078,7 @@ func (s *storageLvm) ContainerCanRestore(container container, sourceContainer co
func lvmContainerDeleteInternal(project, poolName string, ctName string, isSnapshot bool, vgName string, ctPath string) error {
containerMntPoint := ""
- containerLvmName := containerNameToLVName(ctName)
+ containerLvmName := containerNameToLVName(projectPrefix(project, ctName))
if isSnapshot {
containerMntPoint = getSnapshotMountPoint(project, poolName, ctName)
} else {
@@ -1251,7 +1251,7 @@ func (s *storageLvm) ContainerMount(c container) (bool, error) {
func (s *storageLvm) doContainerMount(project, name string) (bool, error) {
logger.Debugf("Mounting LVM storage volume for container \"%s\" on storage pool \"%s\"", s.volume.Name, s.pool.Name)
- containerLvmName := containerNameToLVName(name)
+ containerLvmName := containerNameToLVName(projectPrefix(project, name))
lvFsType := s.getLvmFilesystem()
poolName := s.getOnDiskPoolName()
containerLvmPath := getLvmDevPath(project, poolName, storagePoolVolumeAPIEndpointContainers, containerLvmName)
@@ -1571,7 +1571,7 @@ func (s *storageLvm) ContainerSnapshotStart(container container) (bool, error) {
poolName := s.getOnDiskPoolName()
containerName := container.Name()
- containerLvmName := containerNameToLVName(containerName)
+ containerLvmName := containerNameToLVName(projectPrefix(container.Name(), containerName))
containerLvmPath := getLvmDevPath(container.Project(), poolName, storagePoolVolumeAPIEndpointContainers, containerLvmName)
wasWritableAtCheck, err := lvmLvIsWritable(containerLvmPath)
@@ -1623,7 +1623,7 @@ func (s *storageLvm) ContainerSnapshotStop(container container) (bool, error) {
snapshotMntPoint := getSnapshotMountPoint(container.Project(), s.pool.Name, containerName)
poolName := s.getOnDiskPoolName()
- containerLvmName := containerNameToLVName(containerName)
+ containerLvmName := containerNameToLVName(projectPrefix(container.Project(), containerName))
if shared.IsMountPoint(snapshotMntPoint) {
err := tryUnmount(snapshotMntPoint, 0)
@@ -1832,7 +1832,7 @@ func (s *storageLvm) doContainerBackupLoad(project, containerName string, privil
} else {
containerPath = shared.VarPath("containers", projectPrefix(project, containerName))
}
- containerLvmName := containerNameToLVName(containerName)
+ containerLvmName := containerNameToLVName(projectPrefix(project, containerName))
thinPoolName := s.getLvmThinpoolName()
lvFsType := s.getLvmFilesystem()
lvSize, err := s.getLvmVolumeSize()
diff --git a/lxd/storage_lvm_utils.go b/lxd/storage_lvm_utils.go
index d16175dbbf..cf418dde6e 100644
--- a/lxd/storage_lvm_utils.go
+++ b/lxd/storage_lvm_utils.go
@@ -308,7 +308,7 @@ func (s *storageLvm) copyContainerThinpool(target container, source container, r
LVFilesystem := s.getLvmFilesystem()
poolName := s.getOnDiskPoolName()
containerName := target.Name()
- containerLvmName := containerNameToLVName(containerName)
+ containerLvmName := containerNameToLVName(projectPrefix(target.Name(), containerName))
containerLvDevPath := getLvmDevPath(target.Project(), poolName,
storagePoolVolumeAPIEndpointContainers, containerLvmName)
@@ -564,7 +564,7 @@ func (s *storageLvm) containerCreateFromImageThinLv(c container, fp string) erro
}
containerName := c.Name()
- containerLvmName := containerNameToLVName(containerName)
+ containerLvmName := containerNameToLVName(projectPrefix(c.Project(), containerName))
_, err := s.createSnapshotLV(c.Project(), poolName, fp, storagePoolVolumeAPIEndpointImages, containerLvmName, storagePoolVolumeAPIEndpointContainers, false, s.useThinpool)
if err != nil {
return errors.Wrap(err, "Create snapshot")
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <***@ubuntu.com>
Date: Fri, 30 Nov 2018 13:29:13 -0500
Subject: [PATCH] lxd/storage/lvm: Fix project handling
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <***@ubuntu.com>
---
lxd/storage_lvm.go | 16 ++++++++--------
lxd/storage_lvm_utils.go | 4 ++--
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/lxd/storage_lvm.go b/lxd/storage_lvm.go
index 5377c0a49b..3745dff293 100644
--- a/lxd/storage_lvm.go
+++ b/lxd/storage_lvm.go
@@ -919,7 +919,7 @@ func (s *storageLvm) StoragePoolVolumeRename(newName string) error {
}
func (s *storageLvm) ContainerStorageReady(container container) bool {
- containerLvmName := containerNameToLVName(container.Name())
+ containerLvmName := containerNameToLVName(projectPrefix(container.Project(), container.Name()))
poolName := s.getOnDiskPoolName()
containerLvmPath := getLvmDevPath(container.Project(), poolName, storagePoolVolumeAPIEndpointContainers, containerLvmName)
ok, _ := storageLVExists(containerLvmPath)
@@ -932,7 +932,7 @@ func (s *storageLvm) ContainerCreate(container container) error {
tryUndo := true
containerName := container.Name()
- containerLvmName := containerNameToLVName(containerName)
+ containerLvmName := containerNameToLVName(projectPrefix(container.Project(), containerName))
thinPoolName := s.getLvmThinpoolName()
lvFsType := s.getLvmFilesystem()
lvSize, err := s.getLvmVolumeSize()
@@ -996,7 +996,7 @@ func (s *storageLvm) ContainerCreateFromImage(container container, fingerprint s
tryUndo := true
containerName := container.Name()
- containerLvmName := containerNameToLVName(containerName)
+ containerLvmName := containerNameToLVName(projectPrefix(container.Project(), containerName))
var err error
if s.useThinpool {
@@ -1078,7 +1078,7 @@ func (s *storageLvm) ContainerCanRestore(container container, sourceContainer co
func lvmContainerDeleteInternal(project, poolName string, ctName string, isSnapshot bool, vgName string, ctPath string) error {
containerMntPoint := ""
- containerLvmName := containerNameToLVName(ctName)
+ containerLvmName := containerNameToLVName(projectPrefix(project, ctName))
if isSnapshot {
containerMntPoint = getSnapshotMountPoint(project, poolName, ctName)
} else {
@@ -1251,7 +1251,7 @@ func (s *storageLvm) ContainerMount(c container) (bool, error) {
func (s *storageLvm) doContainerMount(project, name string) (bool, error) {
logger.Debugf("Mounting LVM storage volume for container \"%s\" on storage pool \"%s\"", s.volume.Name, s.pool.Name)
- containerLvmName := containerNameToLVName(name)
+ containerLvmName := containerNameToLVName(projectPrefix(project, name))
lvFsType := s.getLvmFilesystem()
poolName := s.getOnDiskPoolName()
containerLvmPath := getLvmDevPath(project, poolName, storagePoolVolumeAPIEndpointContainers, containerLvmName)
@@ -1571,7 +1571,7 @@ func (s *storageLvm) ContainerSnapshotStart(container container) (bool, error) {
poolName := s.getOnDiskPoolName()
containerName := container.Name()
- containerLvmName := containerNameToLVName(containerName)
+ containerLvmName := containerNameToLVName(projectPrefix(container.Name(), containerName))
containerLvmPath := getLvmDevPath(container.Project(), poolName, storagePoolVolumeAPIEndpointContainers, containerLvmName)
wasWritableAtCheck, err := lvmLvIsWritable(containerLvmPath)
@@ -1623,7 +1623,7 @@ func (s *storageLvm) ContainerSnapshotStop(container container) (bool, error) {
snapshotMntPoint := getSnapshotMountPoint(container.Project(), s.pool.Name, containerName)
poolName := s.getOnDiskPoolName()
- containerLvmName := containerNameToLVName(containerName)
+ containerLvmName := containerNameToLVName(projectPrefix(container.Project(), containerName))
if shared.IsMountPoint(snapshotMntPoint) {
err := tryUnmount(snapshotMntPoint, 0)
@@ -1832,7 +1832,7 @@ func (s *storageLvm) doContainerBackupLoad(project, containerName string, privil
} else {
containerPath = shared.VarPath("containers", projectPrefix(project, containerName))
}
- containerLvmName := containerNameToLVName(containerName)
+ containerLvmName := containerNameToLVName(projectPrefix(project, containerName))
thinPoolName := s.getLvmThinpoolName()
lvFsType := s.getLvmFilesystem()
lvSize, err := s.getLvmVolumeSize()
diff --git a/lxd/storage_lvm_utils.go b/lxd/storage_lvm_utils.go
index d16175dbbf..cf418dde6e 100644
--- a/lxd/storage_lvm_utils.go
+++ b/lxd/storage_lvm_utils.go
@@ -308,7 +308,7 @@ func (s *storageLvm) copyContainerThinpool(target container, source container, r
LVFilesystem := s.getLvmFilesystem()
poolName := s.getOnDiskPoolName()
containerName := target.Name()
- containerLvmName := containerNameToLVName(containerName)
+ containerLvmName := containerNameToLVName(projectPrefix(target.Name(), containerName))
containerLvDevPath := getLvmDevPath(target.Project(), poolName,
storagePoolVolumeAPIEndpointContainers, containerLvmName)
@@ -564,7 +564,7 @@ func (s *storageLvm) containerCreateFromImageThinLv(c container, fp string) erro
}
containerName := c.Name()
- containerLvmName := containerNameToLVName(containerName)
+ containerLvmName := containerNameToLVName(projectPrefix(c.Project(), containerName))
_, err := s.createSnapshotLV(c.Project(), poolName, fp, storagePoolVolumeAPIEndpointImages, containerLvmName, storagePoolVolumeAPIEndpointContainers, false, s.useThinpool)
if err != nil {
return errors.Wrap(err, "Create snapshot")