From 5b0a65e9a335f4441c8046c342c1f7a61b39f3a7 Mon Sep 17 00:00:00 2001 From: Tim Hockin Date: Sun, 11 Jan 2015 16:40:06 -0800 Subject: [PATCH] make private root dirs for integration test kubelets --- cmd/integration/integration.go | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/cmd/integration/integration.go b/cmd/integration/integration.go index 64319c2bb64..1333ca9b064 100644 --- a/cmd/integration/integration.go +++ b/cmd/integration/integration.go @@ -24,6 +24,7 @@ import ( "net" "net/http" "net/http/httptest" + "os" "reflect" "runtime" "strconv" @@ -55,9 +56,6 @@ import ( "github.com/golang/glog" ) -const testRootDir = "/tmp/kubelet" -const testRootDir2 = "/tmp/kubelet2" - var ( fakeDocker1, fakeDocker2 dockertools.FakeDockerClient ) @@ -192,15 +190,30 @@ func startComponents(manifestURL string) (apiServerURL string) { nodeController.Run(10 * time.Second) // Kubelet (localhost) + testRootDir := makeTempDirOrDie("kubelet_integ_1.") + glog.Infof("Using %s as root dir for kubelet #1", testRootDir) standalone.SimpleRunKubelet(cl, etcdClient, &fakeDocker1, machineList[0], testRootDir, manifestURL, "127.0.0.1", 10250) // Kubelet (machine) // Create a second kubelet so that the guestbook example's two redis slaves both // have a place they can schedule. - standalone.SimpleRunKubelet(cl, etcdClient, &fakeDocker2, machineList[1], testRootDir2, "", "127.0.0.1", 10251) + testRootDir = makeTempDirOrDie("kubelet_integ_2.") + glog.Infof("Using %s as root dir for kubelet #2", testRootDir) + standalone.SimpleRunKubelet(cl, etcdClient, &fakeDocker2, machineList[1], testRootDir, "", "127.0.0.1", 10251) return apiServer.URL } +func makeTempDirOrDie(prefix string) string { + tempDir, err := ioutil.TempDir("/tmp", prefix) + if err != nil { + glog.Fatalf("Can't make a temp rootdir: %v", err) + } + if err = os.MkdirAll(tempDir, 0750); err != nil { + glog.Fatalf("Can't mkdir(%q): %v", tempDir, err) + } + return tempDir +} + // podsOnMinions returns true when all of the selected pods exist on a minion. func podsOnMinions(c *client.Client, pods api.PodList) wait.ConditionFunc { podInfo := fakeKubeletClient{}