From e08920c4fb27b5e626b8890e1c6a3ad114dacc59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Serv=C3=A9n=20Mar=C3=ADn?= Date: Sat, 22 Feb 2020 22:35:31 +0100 Subject: [PATCH] pkg/mesh: allow fully disabling CNI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit fixes the issue encountered in #36, where the CNI config is touched even though CNI management is disabled. Fixes: #36 Signed-off-by: Lucas Servén Marín --- pkg/mesh/mesh.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/mesh/mesh.go b/pkg/mesh/mesh.go index 828726a..d09b466 100644 --- a/pkg/mesh/mesh.go +++ b/pkg/mesh/mesh.go @@ -304,10 +304,12 @@ func (m *Mesh) Run() error { return fmt.Errorf("failed to initialize node backend: %v", err) } // Try to set the CNI config quickly. - if n, err := m.Nodes().Get(m.hostname); err == nil { - if n != nil && n.Subnet != nil { + if m.cni { + if n, err := m.Nodes().Get(m.hostname); err == nil { m.nodes[m.hostname] = n m.updateCNIConfig() + } else { + level.Warn(m.logger).Log("error", fmt.Errorf("failed to get node %q: %v", m.hostname, err)) } } if err := m.Peers().Init(m.stop); err != nil {