[lxc-devel] [lxd/master] lxd/config: Allow modifying cluster.https_address

stgraber on Github lxc-bot at linuxcontainers.org
Sat Sep 14 21:16:54 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 447 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190914/d284f201/attachment.bin>
-------------- next part --------------
From fc3feba953b01976d251cff328769040ebc4ae53 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Sat, 14 Sep 2019 23:15:57 +0200
Subject: [PATCH] lxd/config: Allow modifying cluster.https_address
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This allows modifying cluster.https_address when LXD isn't clustered yet.

Closes #6167

Signed-off-by: St├ęphane Graber <stgraber at ubuntu.com>
---
 lxd/api_1.0.go | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lxd/api_1.0.go b/lxd/api_1.0.go
index cf0b1aea2e..7339ca26b7 100644
--- a/lxd/api_1.0.go
+++ b/lxd/api_1.0.go
@@ -334,9 +334,14 @@ func doApi10Update(d *Daemon, req api.ServerPut, patch bool) Response {
 		}
 	}
 
+	clustered, err := cluster.Enabled(d.db)
+	if err != nil {
+		return InternalError(errors.Wrap(err, "Failed to check for cluster state"))
+	}
+
 	nodeChanged := map[string]string{}
 	var newNodeConfig *node.Config
-	err := d.db.Transaction(func(tx *db.NodeTx) error {
+	err = d.db.Transaction(func(tx *db.NodeTx) error {
 		var err error
 		newNodeConfig, err = node.ConfigLoad(tx)
 		if err != nil {
@@ -348,7 +353,7 @@ func doApi10Update(d *Daemon, req api.ServerPut, patch bool) Response {
 		curClusterAddress := newNodeConfig.ClusterAddress()
 		newClusterAddress, ok := nodeValues["cluster.https_address"]
 
-		if ok && curClusterAddress != "" && !util.IsAddressCovered(newClusterAddress.(string), curClusterAddress) {
+		if clustered && ok && curClusterAddress != "" && !util.IsAddressCovered(newClusterAddress.(string), curClusterAddress) {
 			return fmt.Errorf("Changing cluster.https_address is currently not supported")
 		}
 


More information about the lxc-devel mailing list