[lxc-devel] [lxd/master] lxd/migration: Pre-validate profiles

stgraber on Github lxc-bot at linuxcontainers.org
Fri Mar 30 17:01:12 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 370 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180330/959a6f7d/attachment.bin>
-------------- next part --------------
From ad949e7e05ee8c9eb8d4ed0134d29e5612b6176a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Fri, 30 Mar 2018 13:00:37 -0400
Subject: [PATCH] lxd/migration: Pre-validate profiles
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #4379

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

diff --git a/lxd/containers_post.go b/lxd/containers_post.go
index 0ff9f3370..74a4794be 100644
--- a/lxd/containers_post.go
+++ b/lxd/containers_post.go
@@ -196,6 +196,18 @@ func createFromMigration(d *Daemon, req *api.ContainersPost) Response {
 		Stateful:     req.Stateful,
 	}
 
+	// Early profile validation
+	profiles, err := d.cluster.Profiles()
+	if err != nil {
+		return InternalError(err)
+	}
+
+	for _, profile := range args.Profiles {
+		if !shared.StringInSlice(profile, profiles) {
+			return BadRequest(fmt.Errorf("Requested profile '%s' doesn't exist", profile))
+		}
+	}
+
 	// Grab the container's root device if one is specified
 	storagePool := ""
 	storagePoolProfile := ""


More information about the lxc-devel mailing list