Blob Blame History Raw
From 805d0b60b4e97561f201ea5e457e8c71b067f25b Mon Sep 17 00:00:00 2001
From: Jan Chaloupka <jchaloup@redhat.com>
Date: Thu, 26 Nov 2015 13:00:29 +0100
Subject: [PATCH] keep solid port for kube-proxy

---
 hack/test-cmd.sh | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/hack/test-cmd.sh b/hack/test-cmd.sh
index fb440ac..9daac99 100755
--- a/hack/test-cmd.sh
+++ b/hack/test-cmd.sh
@@ -30,7 +30,6 @@ function stop-proxy()
 {
   [[ -n "${PROXY_PID-}" ]] && kill "${PROXY_PID}" 1>&2 2>/dev/null
   PROXY_PID=
-  PROXY_PORT=
 }
 
 # Starts "kubect proxy" to test the client proxy. $1: api_prefix
@@ -40,18 +39,11 @@ function start-proxy()
 
   kube::log::status "Starting kubectl proxy"
 
-  for retry in $(seq 1 3); do
-    PROXY_PORT=$(kube::util::get_random_port)
-    kube::log::status "On try ${retry}, use proxy port ${PROXY_PORT} if it's free"
-    if kube::util::test_host_port_free "127.0.0.1" "${PROXY_PORT}"; then
-      if [ $# -eq 0 ]; then
-        kubectl proxy -p ${PROXY_PORT} --www=. 1>&2 & break
-      else
-        kubectl proxy -p ${PROXY_PORT} --www=. --api-prefix="$1" 1>&2 & break
-      fi
-    fi
-    sleep 1;
-  done
+  if [ $# -eq 0 ]; then
+    kubectl proxy -p ${PROXY_PORT} --www=. 1>&2 &
+  else
+    kubectl proxy -p ${PROXY_PORT} --www=. --api-prefix="$1" 1>&2 &
+  fi
 
   PROXY_PID=$!
   if [ $# -eq 0 ]; then
@@ -119,6 +111,7 @@ API_HOST=${API_HOST:-127.0.0.1}
 KUBELET_PORT=${KUBELET_PORT:-10250}
 KUBELET_HEALTHZ_PORT=${KUBELET_HEALTHZ_PORT:-10248}
 CTLRMGR_PORT=${CTLRMGR_PORT:-10252}
+PROXY_PORT=${PROXY_PORT:-8001}
 PROXY_HOST=127.0.0.1 # kubectl only serves on localhost.
 
 # ensure ~/.kube/config isn't loaded by tests
-- 
1.9.3