[lxc-devel] [lxd/master] Missing bootstrap error check

SimonRichardson on Github lxc-bot at linuxcontainers.org
Wed Mar 4 20:44:10 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 521 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200304/9d949b86/attachment.bin>
-------------- next part --------------
From 933574fe287d97a1e93939ec8822a45830997295 Mon Sep 17 00:00:00 2001
From: Simon Richardson <stickupkid at gmail.com>
Date: Wed, 4 Mar 2020 20:40:12 +0000
Subject: [PATCH] Missing bootstrap error check

Attempting to patch the cluster.http_address if it's not set isn't
being checked if there is an error loading the configuration or
patching the value.

Signed-off-by: Simon Richardson <simon.richardson at canonical.com>
---
 lxd/api_cluster.go | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lxd/api_cluster.go b/lxd/api_cluster.go
index 8829745e7d..2a668faab1 100644
--- a/lxd/api_cluster.go
+++ b/lxd/api_cluster.go
@@ -234,7 +234,7 @@ func clusterPutBootstrap(d *Daemon, req api.ClusterPut) response.Response {
 
 	// If there's no cluster.https_address set, but core.https_address is,
 	// let's default to it.
-	d.db.Transaction(func(tx *db.NodeTx) error {
+	err := d.db.Transaction(func(tx *db.NodeTx) error {
 		config, err := node.ConfigLoad(tx)
 		if err != nil {
 			return errors.Wrap(err, "Failed to fetch member configuration")
@@ -256,6 +256,9 @@ func clusterPutBootstrap(d *Daemon, req api.ClusterPut) response.Response {
 
 		return nil
 	})
+	if err != nil {
+		return response.SmartError(err)
+	}
 
 	op, err := operations.OperationCreate(d.State(), "", operations.OperationClassTask, db.OperationClusterBootstrap, resources, nil, run, nil, nil)
 	if err != nil {


More information about the lxc-devel mailing list