From 3906dc1afc978510cb841bfe76bb87b490a877fa Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Fri, 25 Sep 2015 18:12:11 -0700 Subject: [PATCH] Fix client init logging and test --- client/client.go | 14 +++++++------- client/client_test.go | 2 ++ 2 files changed, 9 insertions(+), 7 deletions(-) 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)