Fix client init logging and test

This commit is contained in:
Alex Dadgar 2015-09-25 18:12:11 -07:00
parent 70a1a37f84
commit 6ca7c6680d
2 changed files with 9 additions and 7 deletions

View File

@ -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
}

View File

@ -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)