Merge pull request #8192 from hashicorp/fix_7904
use a unique temp dir for each build to prevent concurrent builds fro…
This commit is contained in:
commit
e3257ba088
|
@ -3,6 +3,7 @@ package docker
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
@ -34,16 +35,21 @@ func ConfigTmpDir() (string, error) {
|
|||
configdir = fp
|
||||
}
|
||||
|
||||
td := filepath.Join(configdir, "tmp")
|
||||
_, err = os.Stat(td)
|
||||
_, err = os.Stat(configdir)
|
||||
if os.IsNotExist(err) {
|
||||
log.Printf("Creating tempdir in %s", td)
|
||||
if err = os.MkdirAll(td, 0755); err != nil {
|
||||
log.Printf("Config dir %s does not exist; creating...", configdir)
|
||||
if err = os.MkdirAll(configdir, 0755); err != nil {
|
||||
return "", err
|
||||
}
|
||||
} else if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
td, err := ioutil.TempDir(configdir, "tmp")
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("Error creating temp dir: %s", err)
|
||||
|
||||
}
|
||||
log.Printf("Set Packer temp dir to %s", td)
|
||||
return td, nil
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ func testStepTempDir_impl(t *testing.T) string {
|
|||
dir := dirRaw.(string)
|
||||
|
||||
if _, err := os.Stat(dir); err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
t.Fatalf("Stat for %s failed: err: %s", err, dir)
|
||||
}
|
||||
|
||||
// Cleanup
|
||||
|
|
Loading…
Reference in New Issue