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

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) ===
Hello,

I add a little issue while configuring a CephFS device as described [here](https://lxd.readthedocs.io/en/latest/instances/#devices-configuration):

```
root@ubuntu-focal:~# lxc config device add u1 myfs disk source=cephfs:myfs/ ceph.user_name=admin ceph.cluster_name=ceph path=/cephfs
Error: Failed to start device "myfs": Unable to mount 10.0.0.1:6789:6789,10.0.0.2:6789:6789,10.0.0.3:6789:6789:/ at /var/lib/lxd/devices/u1/disk.myfs.cephfs: invalid argument

root@ubuntu-focal:~# cat /etc/ceph/ceph.conf 
[global]
mon_host = 10.0.0.1:6789,10.0.0.2:6789,10.0.0.3:6789
```

If the `/etc/ceph/$cluster_name.conf` file already has ports configured for the `mon_host` variable, the `diskCephfsOptions` should not append it another time.

This PR checks whether or not the ports should be added.

Thanks,

Léo
From 067cce78cd3eeab97a4926a6ead2eed58a5af7c6 Mon Sep 17 00:00:00 2001
From: Leo Schoukroun <leopau...@yahoo.fr>
Date: Thu, 23 Apr 2020 14:25:18 +0200
Subject: [PATCH 1/2] lxd/device/utils: Fix Ceph typo

---
 lxd/device/device_utils_disk.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lxd/device/device_utils_disk.go b/lxd/device/device_utils_disk.go
index 9047d62446..c5aeb05dd1 100644
--- a/lxd/device/device_utils_disk.go
+++ b/lxd/device/device_utils_disk.go
@@ -207,7 +207,7 @@ func cephFsConfig(clusterName string, userName string) 
([]string, string, error)
        }
 
        if len(cephMon) == 0 {
-               return nil, "", fmt.Errorf("Couldn't find a CPEH mon")
+               return nil, "", fmt.Errorf("Couldn't find a CEPH mon")
        }
 
        // Parse the CEPH keyring

From 53e7efc68b6b7e9df2c42d4b864b1a8b0f1cd527 Mon Sep 17 00:00:00 2001
From: Leo Schoukroun <leopau...@yahoo.fr>
Date: Thu, 23 Apr 2020 16:45:44 +0200
Subject: [PATCH 2/2] lxd/device/utils: Do not add the Ceph mon port if already
 present in /etc/ceph config file

---
 lxd/device/device_utils_disk.go | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lxd/device/device_utils_disk.go b/lxd/device/device_utils_disk.go
index c5aeb05dd1..b79912873e 100644
--- a/lxd/device/device_utils_disk.go
+++ b/lxd/device/device_utils_disk.go
@@ -256,7 +256,12 @@ func diskCephfsOptions(clusterName string, userName 
string, fsName string, fsPat
        fsOptions := fmt.Sprintf("name=%v,secret=%v,mds_namespace=%v", 
userName, secret, fsName)
        srcpath := ""
        for _, monAddress := range monAddresses {
-               srcpath += fmt.Sprintf("%s:6789,", monAddress)
+               // Add the default port to the mon hosts if not already provided
+               if strings.Contains(monAddress, ":6789") {
+        srcpath += fmt.Sprintf("%s,", monAddress)
+    } else {
+        srcpath += fmt.Sprintf("%s:6789,", monAddress)
+    }
        }
        srcpath = srcpath[:len(srcpath)-1]
        srcpath += fmt.Sprintf(":/%s", fsPath)
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to