The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/6638

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) ===
- Removes implied (not actual) project awareness from driver mount path helper utils.
- Fixes rename instance lack of project awareness for symlink.
- Some minor comment improvements.
From 88d9b565713d2091933e48be282785ef8edf4ce7 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parr...@canonical.com>
Date: Fri, 13 Dec 2019 11:40:08 +0000
Subject: [PATCH 1/4] lxd/storage/drivers/interface: Comments on pool
 mount/unmount definitions

Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com>
---
 lxd/storage/drivers/interface.go | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lxd/storage/drivers/interface.go b/lxd/storage/drivers/interface.go
index 9dfed58b15..7bc8e93a02 100644
--- a/lxd/storage/drivers/interface.go
+++ b/lxd/storage/drivers/interface.go
@@ -28,7 +28,12 @@ type Driver interface {
        // Pool.
        Create() error
        Delete(op *operations.Operation) error
+       // Mount mounts a storage pool if needed, returns true if we caused a 
new mount, false if
+       // already mounted.
        Mount() (bool, error)
+
+       // Unmount unmounts a storage pool if needed, returns true if 
unmounted, false if was not
+       // mounted.
        Unmount() (bool, error)
        GetResources() (*api.ResourcesStoragePool, error)
        Validate(config map[string]string) error

From 5417fd119ab9cbb1c289f34b5fb2f644e5df611c Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parr...@canonical.com>
Date: Fri, 13 Dec 2019 14:13:29 +0000
Subject: [PATCH 2/4] shared/util: Adds comment to TryRunCommand

Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com>
---
 shared/util.go | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/shared/util.go b/shared/util.go
index e307f985fe..0a80f5dd7e 100644
--- a/shared/util.go
+++ b/shared/util.go
@@ -861,6 +861,8 @@ func RunCommandWithFds(stdin io.Reader, stdout io.Writer, 
name string, arg ...st
        return nil
 }
 
+// TryRunCommand runs the specified command up to 20 times with a 500ms delay 
between each call
+// until it runs without an error. If after 20 times it is still failing then 
returns the error.
 func TryRunCommand(name string, arg ...string) (string, error) {
        var err error
        var output string

From 0fa2bc7d2001f249ee5992ddcad7fe6d735674a8 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parr...@canonical.com>
Date: Tue, 17 Dec 2019 17:03:59 +0000
Subject: [PATCH 3/4] lxd/storage/backend/lxd: Fixes bug with non-project aware
 vol storage name in RenameInstance

Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com>
---
 lxd/storage/backend_lxd.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lxd/storage/backend_lxd.go b/lxd/storage/backend_lxd.go
index 0c89abdaa2..faa57209eb 100644
--- a/lxd/storage/backend_lxd.go
+++ b/lxd/storage/backend_lxd.go
@@ -1079,7 +1079,7 @@ func (b *lxdBackend) RenameInstance(inst 
instance.Instance, newName string, op *
                return err
        }
 
-       err = b.ensureInstanceSymlink(inst.Type(), inst.Project(), newName, 
drivers.GetVolumeMountPath(b.name, volType, newName))
+       err = b.ensureInstanceSymlink(inst.Type(), inst.Project(), newName, 
drivers.GetVolumeMountPath(b.name, volType, newVolStorageName))
        if err != nil {
                return err
        }

From fbfe9f34af084fd49df04e7c52faf7c9308e6b66 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parr...@canonical.com>
Date: Tue, 17 Dec 2019 17:04:38 +0000
Subject: [PATCH 4/4] lxd/storage/drivers/utils: Removes implication of project
 awareness from driver mount point helpers

Drivers are not project aware, and instead rely on the volume name to be 
prefixed with project before being passed into driver.

Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com>
---
 lxd/storage/drivers/utils.go | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/lxd/storage/drivers/utils.go b/lxd/storage/drivers/utils.go
index 1ae7cdbfd5..f4df80eac8 100644
--- a/lxd/storage/drivers/utils.go
+++ b/lxd/storage/drivers/utils.go
@@ -10,7 +10,6 @@ import (
 
        "golang.org/x/sys/unix"
 
-       "github.com/lxc/lxd/lxd/project"
        "github.com/lxc/lxd/shared"
 )
 
@@ -149,20 +148,19 @@ func GetPoolMountPath(poolName string) string {
 }
 
 // GetVolumeMountPath returns the mount path for a specific volume based on 
its pool and type and
-// whether it is a snapshot or not.
-// For VolumeTypeImage the volName is the image fingerprint.
+// whether it is a snapshot or not. For VolumeTypeImage the volName is the 
image fingerprint.
 func GetVolumeMountPath(poolName string, volType VolumeType, volName string) 
string {
        if shared.IsSnapshot(volName) {
-               return shared.VarPath("storage-pools", poolName, 
fmt.Sprintf("%s-snapshots", string(volType)), project.Prefix("default", 
volName))
+               return shared.VarPath("storage-pools", poolName, 
fmt.Sprintf("%s-snapshots", string(volType)), volName)
        }
 
-       return shared.VarPath("storage-pools", poolName, string(volType), 
project.Prefix("default", volName))
+       return shared.VarPath("storage-pools", poolName, string(volType), 
volName)
 }
 
 // GetVolumeSnapshotDir gets the snapshot mount directory for the parent 
volume.
 func GetVolumeSnapshotDir(poolName string, volType VolumeType, volName string) 
string {
        parent, _, _ := shared.InstanceGetParentAndSnapshotName(volName)
-       return shared.VarPath("storage-pools", poolName, 
fmt.Sprintf("%s-snapshots", string(volType)), project.Prefix("default", parent))
+       return shared.VarPath("storage-pools", poolName, 
fmt.Sprintf("%s-snapshots", string(volType)), parent)
 }
 
 // GetSnapshotVolumeName returns the full volume name for a parent volume and 
snapshot name.
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to