[lxc-devel] [lxd/master] Project config fixes

stgraber on Github lxc-bot at linuxcontainers.org
Mon Jun 15 00:20:56 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 301 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200614/274357f6/attachment.bin>
-------------- next part --------------
From 33eb77f92810df43126359773d97a5b082690e17 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Sun, 14 Jun 2020 20:17:41 -0400
Subject: [PATCH 1/2] lxd/projects: Properly clear empty keys
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: St├ęphane Graber <stgraber at ubuntu.com>
---
 lxd/db/projects.go | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lxd/db/projects.go b/lxd/db/projects.go
index 295ec8fde1..df19a9601b 100644
--- a/lxd/db/projects.go
+++ b/lxd/db/projects.go
@@ -162,6 +162,10 @@ DELETE FROM projects_config WHERE projects_config.project_id = ?
 	// Insert new config.
 	stmt = c.stmt(projectCreateConfigRef)
 	for key, value := range object.Config {
+		if value == "" {
+			continue
+		}
+
 		_, err := stmt.Exec(id, key, value)
 		if err != nil {
 			return errors.Wrap(err, "Insert config for project")

From 698c63a0434a40251fb0d0ff5bca49d1fdcdd1bc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Sun, 14 Jun 2020 20:19:58 -0400
Subject: [PATCH 2/2] lxd/db: Add missing feature to default project
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Ignore failures as new installs would have them already and I couldn't
figure out a trivial way to ignore conflicts only.

Signed-off-by: St├ęphane Graber <stgraber at ubuntu.com>
---
 lxd/db/cluster/schema.go | 2 +-
 lxd/db/cluster/update.go | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/lxd/db/cluster/schema.go b/lxd/db/cluster/schema.go
index fbf24753fc..ed551c5cda 100644
--- a/lxd/db/cluster/schema.go
+++ b/lxd/db/cluster/schema.go
@@ -553,5 +553,5 @@ CREATE TABLE storage_volumes_snapshots_config (
     UNIQUE (storage_volume_snapshot_id, key)
 );
 
-INSERT INTO schema (version, updated_at) VALUES (28, strftime("%s"))
+INSERT INTO schema (version, updated_at) VALUES (29, strftime("%s"))
 `
diff --git a/lxd/db/cluster/update.go b/lxd/db/cluster/update.go
index fb2c5c73b7..f2bb9f8cfd 100644
--- a/lxd/db/cluster/update.go
+++ b/lxd/db/cluster/update.go
@@ -65,6 +65,13 @@ var updates = map[int]schema.Update{
 	26: updateFromV25,
 	27: updateFromV26,
 	28: updateFromV27,
+	29: updateFromV28,
+}
+
+// Attempt to add missing project feature
+func updateFromV28(tx *sql.Tx) error {
+	tx.Exec("INSERT INTO projects_config (project_id, key, value) VALUES (1, 'features.storage.volumes', 'true');")
+	return nil
 }
 
 // Add expiry date to storage volume snapshots


More information about the lxc-devel mailing list