[lxc-devel] [lxd/master] lxd/migration: Fix handling of missing profiles

stgraber on Github lxc-bot at linuxcontainers.org
Mon Mar 11 20:49:27 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 591 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190311/cb592c46/attachment.bin>
-------------- next part --------------
From ce085570005d161b075d8823373b568be6e822f8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Mon, 11 Mar 2019 16:48:22 -0400
Subject: [PATCH] lxd/migration: Fix handling of missing profiles
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

When Profiles is set to nil, we default to the default profile.

This is normally done by ContainerCreateInternal but in the migration
case we actually need a list of profiles before that's called, so let's
fill it ahead of time.

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/containers_post.go | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lxd/containers_post.go b/lxd/containers_post.go
index 606f40913a..34bc7bb0bc 100644
--- a/lxd/containers_post.go
+++ b/lxd/containers_post.go
@@ -199,6 +199,11 @@ func createFromMigration(d *Daemon, project string, req *api.ContainersPost) Res
 		return BadRequest(err)
 	}
 
+	// Pre-fill default profile
+	if req.Profiles == nil {
+		req.Profiles = []string{"default"}
+	}
+
 	// Prepare the container creation request
 	args := db.ContainerArgs{
 		Project:      project,
@@ -263,9 +268,9 @@ func createFromMigration(d *Daemon, project string, req *api.ContainersPost) Res
 		}
 	}
 
-	logger.Debugf("No valid storage pool in the container's local root disk device and profiles found")
 	// If there is just a single pool in the database, use that
 	if storagePool == "" {
+		logger.Debugf("No valid storage pool in the container's local root disk device and profiles found")
 		pools, err := d.cluster.StoragePools()
 		if err != nil {
 			if err == db.ErrNoSuchObject {


More information about the lxc-devel mailing list