[lxc-devel] [lxd/master] networks: DNS clustered mode is correctly detected during LXD init

tomponline on Github lxc-bot at linuxcontainers.org
Wed Jun 5 16:50:28 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 1088 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190605/cef15a05/attachment.bin>
-------------- next part --------------
From 2b1120571da9bd1377b6e6076cc9f7eafd54f5b5 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Wed, 5 Jun 2019 17:45:19 +0100
Subject: [PATCH] networks: DNS clustered mode is correctly detected during LXD
 init

Ensures that DNS clustered mode is correctly enabled when starting the networks, even if the network is being started as part of LXD init before a cluster has been setup.

This has the effect of starting dnsmasq and forkdns with the correct settings for clustered mode.

It uses the node.ClusterAddress() to indicate an intention for the node to join a cluster at some point in the future.

Fixes #5805

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

diff --git a/lxd/networks.go b/lxd/networks.go
index cfe80df9ed..6eeb3d00bc 100644
--- a/lxd/networks.go
+++ b/lxd/networks.go
@@ -1671,11 +1671,19 @@ func (n *network) Start() error {
 		}
 
 		// Setup clustered DNS
-		dnsClustered, err = cluster.Enabled(n.state.Node)
+		clusterAddress, err := node.ClusterAddress(n.state.Node)
 		if err != nil {
 			return err
 		}
 
+		// If clusterAddress is non-empty, this indicates the intention for this node to be
+		// part of a cluster and so we should ensure that dnsmasq and forkdns are started
+		// in cluster mode. Note: During LXD initialisation the cluster may not actually be
+		// setup yet, but we want the DNS processes to be ready for when it is.
+		if clusterAddress != "" {
+			dnsClustered = true
+		}
+
 		dnsClusteredAddress = strings.Split(fanAddress, "/")[0]
 	}
 


More information about the lxc-devel mailing list