[lxc-devel] [lxd/master] Fix bad schema update
stgraber on Github
lxc-bot at linuxcontainers.org
Thu Oct 5 17:04:07 UTC 2017
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/20171005/48d41be2/attachment.bin>
-------------- next part --------------
From cc90c9f9bac27c204b63aa6057faa2d8d091fc61 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Thu, 5 Oct 2017 12:59:14 -0400
Subject: [PATCH 1/2] Fix bad DB schema update between schema 30 and 31
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/schema/schema.go | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/lxd/db/schema/schema.go b/lxd/db/schema/schema.go
index d80f37db7..795bc6af9 100644
--- a/lxd/db/schema/schema.go
+++ b/lxd/db/schema/schema.go
@@ -7,6 +7,7 @@ import (
"strings"
"github.com/lxc/lxd/lxd/db/query"
+ "github.com/lxc/lxd/shared"
)
// Schema captures the schema of a database in terms of a series of ordered
@@ -164,6 +165,19 @@ func ensureUpdatesAreApplied(tx *sql.Tx, updates []Update, hook Hook) error {
return fmt.Errorf("failed to fetch update versions: %v", err)
}
+ // Fix bad upgrade code between 30 and 32
+ if shared.IntInSlice(30, versions) && shared.IntInSlice(32, versions) && !shared.IntInSlice(31, versions) {
+ err = insertSchemaVersion(tx, 31)
+ if err != nil {
+ return fmt.Errorf("failed to insert missing schema version 31")
+ }
+
+ versions, err = selectSchemaVersions(tx)
+ if err != nil {
+ return fmt.Errorf("failed to fetch update versions: %v", err)
+ }
+ }
+
current := 0
if len(versions) > 0 {
err = checkSchemaVersionsHaveNoHoles(versions)
From d4bfd1ad16d6a8d2cad2bfcf446da6a1ac72e6db Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 3 Oct 2017 17:36:03 -0400
Subject: [PATCH 2/2] images: Fix bad error message
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/images.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lxd/images.go b/lxd/images.go
index 973ed8500..eb3a3dabf 100644
--- a/lxd/images.go
+++ b/lxd/images.go
@@ -945,7 +945,7 @@ func autoUpdateImage(d *Daemon, op *operation, id int, info *api.Image) error {
if info.Cached {
err = db.ImageLastAccessInit(d.db, hash)
if err != nil {
- logger.Error("Error moving aliases", log.Ctx{"err": err, "fp": hash})
+ logger.Error("Error setting cached flag", log.Ctx{"err": err, "fp": hash})
continue
}
}
More information about the lxc-devel
mailing list