[lxc-devel] [lxd/master] cluster/heartbeat: Fixes bug when nodes join during heartbeat

tomponline on Github lxc-bot at linuxcontainers.org
Mon Jul 8 23:05:35 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 444 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190708/797955af/attachment-0001.bin>
-------------- next part --------------
From 38a6cb1ab1d58fd493d12d9451e40ed3b43c84af Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Tue, 9 Jul 2019 00:04:29 +0100
Subject: [PATCH] cluster/heartbeat: Fixes bug when nodes join during heartbeat

Previously new nodes were not detected if they joined during heartbeat process.

Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
 lxd/cluster/heartbeat.go | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lxd/cluster/heartbeat.go b/lxd/cluster/heartbeat.go
index 2833bc92b2..4ca23fc7f8 100644
--- a/lxd/cluster/heartbeat.go
+++ b/lxd/cluster/heartbeat.go
@@ -116,7 +116,7 @@ func Heartbeat(gateway *Gateway, cluster *db.Cluster) (task.Func, task.Schedule)
 		var currentNodes []db.NodeInfo
 		err = cluster.Transaction(func(tx *db.ClusterTx) error {
 			var err error
-			nodes, err = tx.Nodes()
+			currentNodes, err = tx.Nodes()
 			if err != nil {
 				return err
 			}
@@ -139,6 +139,7 @@ func Heartbeat(gateway *Gateway, cluster *db.Cluster) (task.Func, task.Schedule)
 
 			if !found {
 				// We found a new node
+				nodes = append(nodes, currentNode)
 				heartbeatsWg.Add(1)
 				go sendHeartbeat(currentNode.ID, currentNode.Address, false)
 			}


More information about the lxc-devel mailing list