[lxc-devel] [lxd/master] Fix more err == nil checks and cleanup UsedBy for profiles
stgraber on Github
lxc-bot at linuxcontainers.org
Mon Aug 27 19:09:02 UTC 2018
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/20180827/278860a7/attachment.bin>
-------------- next part --------------
From 66327edca6a283a73a1c1c403351ca23fb21fd77 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Sun, 26 Aug 2018 19:37:22 -0400
Subject: [PATCH 1/2] client: Avoid err == nil pattern
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>
---
client/util.go | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/client/util.go b/client/util.go
index 784aab9efe..3826c138e1 100644
--- a/client/util.go
+++ b/client/util.go
@@ -110,9 +110,9 @@ func remoteOperationError(msg string, errors map[string]error) error {
}
// Check if successful
- if err == nil {
- return nil
+ if err != nil {
+ return fmt.Errorf("%s: %s", msg, err)
}
- return fmt.Errorf("%s: %s", msg, err)
+ return nil
}
From b3b802b41c22d009325a7d2c2a37b5b8d168ab58 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Sun, 26 Aug 2018 20:37:01 -0400
Subject: [PATCH 2/2] lxd/profiles: Don't list snapshots in UsedBy
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/profiles.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lxd/db/profiles.go b/lxd/db/profiles.go
index f6e55de54b..b990b0b06f 100644
--- a/lxd/db/profiles.go
+++ b/lxd/db/profiles.go
@@ -237,7 +237,7 @@ func (c *Cluster) ProfileContainersGet(profile string) ([]string, error) {
q := `SELECT containers.name FROM containers JOIN containers_profiles
ON containers.id == containers_profiles.container_id
JOIN profiles ON containers_profiles.profile_id == profiles.id
- WHERE profiles.name == ?`
+ WHERE profiles.name == ? AND containers.type == 0`
results := []string{}
inargs := []interface{}{profile}
More information about the lxc-devel
mailing list