Browse Source

pkg/mesh: allow fully disabling CNI

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 <lserven@gmail.com>
Lucas Servén Marín 6 years ago
parent
commit
e08920c4fb
1 changed files with 4 additions and 2 deletions
  1. 4 2
      pkg/mesh/mesh.go

+ 4 - 2
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 {