Skip to content

Commit

Permalink
Merge pull request kubernetes#24512 from freehan/goproxyflake
Browse files Browse the repository at this point in the history
reuse goproxy pod and avoid race between kubectl exec and goproxy readiness
  • Loading branch information
roberthbailey committed May 6, 2016
2 parents 375d2ad + 1993bf9 commit 18a829e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
28 changes: 14 additions & 14 deletions test/e2e/kubectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,20 +408,20 @@ var _ = framework.KubeDescribe("Kubectl client", func() {
framework.Failf("Unable to upload kubectl binary to remote exec server. /uploads/ not in response. Response: %s", uploadBinaryName)
}

for _, proxyVar := range []string{"https_proxy", "HTTPS_PROXY"} {
By("Running kubectl in netexec via an HTTP proxy using " + proxyVar)
// start the proxy container
goproxyPodPath := filepath.Join(framework.TestContext.RepoRoot, "test/images/goproxy/pod.yaml")
framework.RunKubectlOrDie("create", "-f", goproxyPodPath, fmt.Sprintf("--namespace=%v", ns))
framework.CheckPodsRunningReady(c, ns, []string{goproxyContainer}, framework.PodStartTimeout)
By("Starting goproxy pod")
goproxyPodPath := filepath.Join(framework.TestContext.RepoRoot, "test/images/goproxy/pod.yaml")
framework.RunKubectlOrDie("create", "-f", goproxyPodPath, fmt.Sprintf("--namespace=%v", ns))
framework.CheckPodsRunningReady(c, ns, []string{goproxyContainer}, framework.PodStartTimeout)

// get the proxy address
goproxyPod, err := c.Pods(ns).Get(goproxyContainer)
if err != nil {
framework.Failf("Unable to get the goproxy pod. Error: %s", err)
}
proxyAddr := fmt.Sprintf("http://%s:8080", goproxyPod.Status.PodIP)
// get the proxy address
goproxyPod, err := c.Pods(ns).Get(goproxyContainer)
if err != nil {
framework.Failf("Unable to get the goproxy pod. Error: %s", err)
}
proxyAddr := fmt.Sprintf("http://%s:8080", goproxyPod.Status.PodIP)

for _, proxyVar := range []string{"https_proxy", "HTTPS_PROXY"} {
By("Running kubectl in netexec via an HTTP proxy using " + proxyVar)
shellCommand := fmt.Sprintf("%s=%s .%s --kubeconfig=%s --server=%s --namespace=%s exec nginx echo running in container",
proxyVar, proxyAddr, uploadBinaryName, kubecConfigRemotePath, apiServer, ns)
framework.Logf("About to remote exec: %v", shellCommand)
Expand Down Expand Up @@ -473,9 +473,9 @@ var _ = framework.KubeDescribe("Kubectl client", func() {
if !strings.Contains(proxyLog, expectedProxyLog) {
framework.Failf("Missing expected log result on proxy server for %s. Expected: %q, got %q", proxyVar, expectedProxyLog, proxyLog)
}
// Clean up the goproxyPod
framework.Cleanup(goproxyPodPath, ns, goproxyPodSelector)
}
// Clean up the goproxyPod
framework.Cleanup(goproxyPodPath, ns, goproxyPodSelector)
})

It("should support inline execution and attach", func() {
Expand Down
4 changes: 4 additions & 0 deletions test/images/goproxy/pod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ spec:
image: gcr.io/google_containers/goproxy:0.1
ports:
- containerPort: 8080
readinessProbe:
tcpSocket:
port: 8080

0 comments on commit 18a829e

Please sign in to comment.