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

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) ===
This closes #4555, and adds more integration tests to cover this particular issue and more behavior in that area.
From 8b57234dcc9a82a95763922b4c4eee82472d6c5c Mon Sep 17 00:00:00 2001
From: Free Ekanayaka <[email protected]>
Date: Mon, 14 May 2018 11:04:59 +0000
Subject: [PATCH 1/2] Consider a copy to be local only when not clustered

Signed-off-by: Free Ekanayaka <[email protected]>
---
 client/lxd_containers.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/client/lxd_containers.go b/client/lxd_containers.go
index b0ad0a8d1..e325283c4 100644
--- a/client/lxd_containers.go
+++ b/client/lxd_containers.go
@@ -250,7 +250,7 @@ func (r *ProtocolLXD) CopyContainer(source ContainerServer, 
container api.Contai
        }
 
        // Optimization for the local copy case
-       if r == source && r.clusterTarget == "" {
+       if r == source && !r.IsClustered() {
                // Local copy source fields
                req.Source.Type = "copy"
                req.Source.Source = container.Name

From d858b5d5f36f30ea8c6ced1603f4a285f53dcc46 Mon Sep 17 00:00:00 2001
From: Free Ekanayaka <[email protected]>
Date: Mon, 14 May 2018 11:47:37 +0000
Subject: [PATCH 2/2] Add integration tests

Signed-off-by: Free Ekanayaka <[email protected]>
---
 test/suites/clustering.sh | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/test/suites/clustering.sh b/test/suites/clustering.sh
index 22fcfc0c6..e3e5b2246 100644
--- a/test/suites/clustering.sh
+++ b/test/suites/clustering.sh
@@ -491,6 +491,46 @@ test_clustering_storage() {
     LXD_DIR="${LXD_ONE_DIR}" lxc image delete testimage
   fi
 
+  # Test migration of zfs/btrfs-based containers
+  if [ "${driver}" = "zfs" ] || [ "${driver}" = "btrfs" ]; then
+    # Launch a container on node2
+    LXD_DIR="${LXD_TWO_DIR}" ensure_import_testimage
+    LXD_DIR="${LXD_ONE_DIR}" lxc launch --target node2 testimage foo
+    LXD_DIR="${LXD_ONE_DIR}" lxc info foo | grep -q "Location: node2"
+
+    # Stop the container and move it to node1
+    LXD_DIR="${LXD_ONE_DIR}" lxc stop foo
+    LXD_DIR="${LXD_TWO_DIR}" lxc move foo bar --target node1
+    LXD_DIR="${LXD_ONE_DIR}" lxc info bar | grep -q "Location: node1"
+
+    # Start and stop the migrated container on node1
+    LXD_DIR="${LXD_TWO_DIR}" lxc start bar
+    LXD_DIR="${LXD_ONE_DIR}" lxc stop bar
+
+    # Rename the container locally on node1
+    LXD_DIR="${LXD_TWO_DIR}" lxc rename bar foo
+    LXD_DIR="${LXD_ONE_DIR}" lxc info foo | grep -q "Location: node1"
+
+    # Copy the container without specifying a target, it will be placed on 
node2
+    # since it's the one with the least number of containers (0 vs 1)
+    LXD_DIR="${LXD_ONE_DIR}" lxc copy foo bar
+    LXD_DIR="${LXD_ONE_DIR}" lxc info bar | grep -q "Location: node2"
+
+    # Start and stop the copied container on node2
+    LXD_DIR="${LXD_TWO_DIR}" lxc start bar
+    LXD_DIR="${LXD_ONE_DIR}" lxc stop bar
+
+    # Purge the containers
+    LXD_DIR="${LXD_ONE_DIR}" lxc delete bar
+    LXD_DIR="${LXD_ONE_DIR}" lxc delete foo
+
+    # Delete the image too, and remove its volumes since they are not
+    # automatically deleted.
+    fp="$(LXD_DIR="${LXD_ONE_DIR}" lxc image list -c f --format json | jq 
.[0].fingerprint)"
+    LXD_DIR="${LXD_ONE_DIR}" lxc image delete testimage
+    LXD_DIR="${LXD_ONE_DIR}" lxc storage volume delete data "image/${fp}"
+  fi
+
   # Delete the storage pool
   LXD_DIR="${LXD_ONE_DIR}" lxc storage delete pool1
   ! LXD_DIR="${LXD_ONE_DIR}" lxc storage list | grep -q pool1
_______________________________________________
lxc-devel mailing list
[email protected]
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to