From 590e8055887e9362f9401d3ec36e1b893b1a6cbb Mon Sep 17 00:00:00 2001 From: Michael Schurter Date: Thu, 5 Sep 2019 12:05:42 -0700 Subject: [PATCH] connect: check if consul is on PATH Only in -dev-connect mode for now since its valid to install Consul after Nomad has started in production. --- command/agent/config.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/command/agent/config.go b/command/agent/config.go index 69a14d766..0767b98f9 100644 --- a/command/agent/config.go +++ b/command/agent/config.go @@ -7,6 +7,7 @@ import ( "io" "net" "os" + "os/exec" "os/user" "path/filepath" "runtime" @@ -705,6 +706,10 @@ func newDevModeConfig(devMode, connectMode bool) (*devModeConfig, error) { return nil, fmt.Errorf( "-dev-connect uses network namespaces and is only supported for root.") } + // Ensure Consul is on PATH + if _, err := exec.LookPath("consul"); err != nil { + return nil, fmt.Errorf("-dev-connect requires a 'consul' binary in Nomad's $PATH") + } mode.connectMode = true } err := mode.networkConfig()