Skip to content

Commit

Permalink
Speedup pkg/kubelet/runonce_test.go
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtek-t committed Mar 12, 2015
1 parent a8f0139 commit dca3db0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 5 additions & 5 deletions pkg/kubelet/runonce.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (kl *Kubelet) RunOnce(updates <-chan PodUpdate) ([]RunPodResult, error) {
select {
case u := <-updates:
glog.Infof("processing manifest with %d pods", len(u.Pods))
result, err := kl.runOnce(u.Pods)
result, err := kl.runOnce(u.Pods, RunOnceRetryDelay)
glog.Infof("finished processing %d pods", len(u.Pods))
return result, err
case <-time.After(RunOnceManifestDelay):
Expand All @@ -51,7 +51,7 @@ func (kl *Kubelet) RunOnce(updates <-chan PodUpdate) ([]RunPodResult, error) {
}

// runOnce runs a given set of pods and returns their status.
func (kl *Kubelet) runOnce(pods []api.BoundPod) (results []RunPodResult, err error) {
func (kl *Kubelet) runOnce(pods []api.BoundPod, retryDelay time.Duration) (results []RunPodResult, err error) {
if kl.dockerPuller == nil {
kl.dockerPuller = dockertools.NewDockerPuller(kl.dockerClient, kl.pullQPS, kl.pullBurst)
}
Expand All @@ -61,7 +61,7 @@ func (kl *Kubelet) runOnce(pods []api.BoundPod) (results []RunPodResult, err err
for i := range pods {
pod := pods[i] // Make a copy
go func() {
err := kl.runPod(pod)
err := kl.runPod(pod, retryDelay)
ch <- RunPodResult{&pod, err}
}()
}
Expand All @@ -87,8 +87,8 @@ func (kl *Kubelet) runOnce(pods []api.BoundPod) (results []RunPodResult, err err
}

// runPod runs a single pod and wait until all containers are running.
func (kl *Kubelet) runPod(pod api.BoundPod) error {
delay := RunOnceRetryDelay
func (kl *Kubelet) runPod(pod api.BoundPod, retryDelay time.Duration) error {
delay := retryDelay
retry := 0
for {
dockerContainers, err := dockertools.GetKubeletDockerContainers(kl.dockerClient, false)
Expand Down
3 changes: 2 additions & 1 deletion pkg/kubelet/runonce_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"
"strconv"
"testing"
"time"

"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/record"
Expand Down Expand Up @@ -140,7 +141,7 @@ func TestRunOnce(t *testing.T) {
},
},
},
})
}, time.Millisecond)
if err != nil {
t.Errorf("unexpected error: %v", err)
}
Expand Down

0 comments on commit dca3db0

Please sign in to comment.