[lxc-devel] [lxd/master] lxd/cluster/upgrade: Prevents crash if heartbeat occurs before dqlite…

tomponline on Github lxc-bot at linuxcontainers.org
Mon Sep 9 19:44:52 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 373 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190909/9655d3b5/attachment.bin>
-------------- next part --------------
From 0aaac84a42f6af11d2c0d70ea378f0bf25d254b7 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Mon, 9 Sep 2019 20:44:01 +0100
Subject: [PATCH] lxd/cluster/upgrade: Prevents crash if heartbeat occurs
 before dqlite init

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

diff --git a/lxd/cluster/upgrade.go b/lxd/cluster/upgrade.go
index b7c1440867..a3ddd4d75a 100644
--- a/lxd/cluster/upgrade.go
+++ b/lxd/cluster/upgrade.go
@@ -65,6 +65,10 @@ func MaybeUpdate(state *state.State) error {
 		return nil
 	}
 
+	if state.Cluster == nil {
+		return fmt.Errorf("Failed checking cluster update, state not initialised yet")
+	}
+
 	err = state.Cluster.Transaction(func(tx *db.ClusterTx) error {
 		outdated, err := tx.NodeIsOutdated()
 		if err != nil {


More information about the lxc-devel mailing list