diff --git a/client/client.go b/client/client.go index 0b4912583..148cee4c7 100644 --- a/client/client.go +++ b/client/client.go @@ -156,15 +156,15 @@ func (c *Client) init() error { if err := os.MkdirAll(c.config.AllocDir, 0700); err != nil { return fmt.Errorf("failed creating alloc dir: %s", err) } + } else { + // Othewise make a temp directory to use. + p, err := ioutil.TempDir("", "NomadClient") + if err != nil { + return fmt.Errorf("failed creating temporary directory for the AllocDir: %v", err) + } + c.config.AllocDir = p } - // Othewise make a temp directory to use. - p, err := ioutil.TempDir("", "NomadClient") - if err != nil { - return fmt.Errorf("failed creating temporary directory for the AllocDir: %v", err) - } - c.config.AllocDir = p - c.logger.Printf("[INFO] client: using alloc directory %v", c.config.AllocDir) return nil } diff --git a/client/client_test.go b/client/client_test.go index 2218700f2..27f26e1c2 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -3,6 +3,7 @@ package client import ( "fmt" "io/ioutil" + "log" "net" "os" "path/filepath" @@ -393,6 +394,7 @@ func TestClient_Init(t *testing.T) { config: &config.Config{ AllocDir: allocDir, }, + logger: log.New(os.Stderr, "", log.LstdFlags), } if err := client.init(); err != nil { t.Fatalf("err: %s", err)