[lxc-devel] [lxd/master] Fix ignored database errors

freeekanayaka on Github lxc-bot at linuxcontainers.org
Mon Mar 26 09:00:38 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 429 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180326/2aa6605f/attachment.bin>
-------------- next part --------------
From b8e2ed14de26b6743d5b9f5d22f763e46959d738 Mon Sep 17 00:00:00 2001
From: Free Ekanayaka <free.ekanayaka at canonical.com>
Date: Mon, 26 Mar 2018 08:58:41 +0000
Subject: [PATCH] Fix ignored database errors

Fix a few spots were database errors were effectively swallowed.

Signed-off-by: Free Ekanayaka <free.ekanayaka at canonical.com>
---
 lxd/db/storage_pools.go   | 5 ++++-
 lxd/db/storage_volumes.go | 2 ++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/lxd/db/storage_pools.go b/lxd/db/storage_pools.go
index 050157d01..60edffd1a 100644
--- a/lxd/db/storage_pools.go
+++ b/lxd/db/storage_pools.go
@@ -998,7 +998,10 @@ AND storage_volumes.name=? AND storage_volumes.type=?`
 
 	err := dbQueryRowScan(c.db, query, inargs, outargs)
 	if err != nil {
-		return -1, NoSuchObjectError
+		if err == sql.ErrNoRows {
+			return -1, NoSuchObjectError
+		}
+		return -1, err
 	}
 
 	return volumeID, nil
diff --git a/lxd/db/storage_volumes.go b/lxd/db/storage_volumes.go
index 151ad7faf..d13576a53 100644
--- a/lxd/db/storage_volumes.go
+++ b/lxd/db/storage_volumes.go
@@ -69,6 +69,7 @@ SELECT nodes.name FROM storage_volumes
 		if err == sql.ErrNoRows {
 			return "", NoSuchObjectError
 		}
+		return "", err
 	}
 
 	return name, nil
@@ -110,6 +111,7 @@ func (c *Cluster) StorageVolumeDescriptionGet(volumeID int64) (string, error) {
 		if err == sql.ErrNoRows {
 			return "", NoSuchObjectError
 		}
+		return "", err
 	}
 
 	return description.String, nil


More information about the lxc-devel mailing list