The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/6631
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) ===
From 3add6e106f833bd7efcc2bb0f693e1033b844595 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com> Date: Mon, 16 Dec 2019 15:19:16 -0500 Subject: [PATCH 1/3] lxd/storage/drivers: Re-order utils MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber <stgra...@ubuntu.com> --- lxd/storage/drivers/utils.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lxd/storage/drivers/utils.go b/lxd/storage/drivers/utils.go index dc6b2fd87c..1ae7cdbfd5 100644 --- a/lxd/storage/drivers/utils.go +++ b/lxd/storage/drivers/utils.go @@ -14,11 +14,6 @@ import ( "github.com/lxc/lxd/shared" ) -// MkfsOptions represents options for filesystem creation. -type MkfsOptions struct { - Label string -} - func wipeDirectory(path string) error { // List all entries entries, err := ioutil.ReadDir(path) @@ -231,6 +226,11 @@ func createSparseFile(filePath string, sizeBytes int64) error { return nil } +// MkfsOptions represents options for filesystem creation. +type MkfsOptions struct { + Label string +} + // MakeFSType creates the provided filesystem. func MakeFSType(path string, fsType string, options *MkfsOptions) (string, error) { var err error From b990d04be55691b898a8a3a02767c6ea37e996ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com> Date: Mon, 16 Dec 2019 15:23:12 -0500 Subject: [PATCH 2/3] lxd/storage: Move BaseDirectories to drivers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber <stgra...@ubuntu.com> --- lxd/storage/backend_lxd.go | 2 +- lxd/storage/drivers/volume.go | 8 ++++++++ lxd/storage/utils.go | 7 ------- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lxd/storage/backend_lxd.go b/lxd/storage/backend_lxd.go index 203f9590f7..63faf061c7 100644 --- a/lxd/storage/backend_lxd.go +++ b/lxd/storage/backend_lxd.go @@ -2560,7 +2560,7 @@ func (b *lxdBackend) RestoreCustomVolume(volName string, snapshotName string, op func (b *lxdBackend) createStorageStructure(path string) error { for _, volType := range b.driver.Info().VolumeTypes { - for _, name := range baseDirectories[volType] { + for _, name := range drivers.BaseDirectories[volType] { err := os.MkdirAll(filepath.Join(path, name), 0711) if err != nil && !os.IsExist(err) { return err diff --git a/lxd/storage/drivers/volume.go b/lxd/storage/drivers/volume.go index 8cddd9fe8c..666190ec8d 100644 --- a/lxd/storage/drivers/volume.go +++ b/lxd/storage/drivers/volume.go @@ -34,6 +34,14 @@ const ContentTypeFS = ContentType("fs") // know which filesystem(s) (if any) are in use. const ContentTypeBlock = ContentType("block") +// BaseDirectories maps volume types to the expected directories. +var BaseDirectories = map[VolumeType][]string{ + VolumeTypeContainer: {"containers", "containers-snapshots"}, + VolumeTypeCustom: {"custom", "custom-snapshots"}, + VolumeTypeImage: {"images"}, + VolumeTypeVM: {"virtual-machines", "virtual-machines-snapshots"}, +} + // Volume represents a storage volume, and provides functions to mount and unmount it. type Volume struct { name string diff --git a/lxd/storage/utils.go b/lxd/storage/utils.go index 1ec383dcbc..55d577f736 100644 --- a/lxd/storage/utils.go +++ b/lxd/storage/utils.go @@ -21,13 +21,6 @@ import ( "github.com/lxc/lxd/shared/units" ) -var baseDirectories = map[drivers.VolumeType][]string{ - drivers.VolumeTypeContainer: {"containers", "containers-snapshots"}, - drivers.VolumeTypeCustom: {"custom", "custom-snapshots"}, - drivers.VolumeTypeImage: {"images"}, - drivers.VolumeTypeVM: {"virtual-machines", "virtual-machines-snapshots"}, -} - // VolumeUsedByInstancesWithProfiles returns a slice containing the names of instances using a volume. var VolumeUsedByInstancesWithProfiles func(s *state.State, poolName string, volumeName string, volumeTypeName string, runningOnly bool) ([]string, error) From e8c3824cd007077657f3aa176a927ce47841126e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com> Date: Mon, 16 Dec 2019 15:25:46 -0500 Subject: [PATCH 3/3] lxd/storage/cephfs: Don't hardcode directory names MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber <stgra...@ubuntu.com> --- lxd/storage/drivers/driver_cephfs.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lxd/storage/drivers/driver_cephfs.go b/lxd/storage/drivers/driver_cephfs.go index b4923586e3..6c63190390 100644 --- a/lxd/storage/drivers/driver_cephfs.go +++ b/lxd/storage/drivers/driver_cephfs.go @@ -192,11 +192,13 @@ func (d *cephfs) Delete(op *operations.Operation) error { if shared.PathExists(filepath.Join(mountPoint, fsPath)) { // Delete the usual directories. - for _, dir := range []string{"custom", "custom-snapshots"} { - if shared.PathExists(filepath.Join(mountPoint, fsPath, dir)) { - err = os.Remove(filepath.Join(mountPoint, fsPath, dir)) - if err != nil { - return err + for _, volType := range d.Info().VolumeTypes { + for _, dir := range BaseDirectories[volType] { + if shared.PathExists(filepath.Join(mountPoint, fsPath, dir)) { + err = os.Remove(filepath.Join(mountPoint, fsPath, dir)) + if err != nil { + return err + } } } }
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel