From c4b6824f07ed3f0c46e5ef26f8d439229ebd9c31 Mon Sep 17 00:00:00 2001 From: David Lyle Date: Fri, 26 Jul 2019 08:43:13 -0600 Subject: [PATCH] Fixing proxy process management --- metrics/scaling/k8s_scale.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/metrics/scaling/k8s_scale.sh b/metrics/scaling/k8s_scale.sh index 5daec93..7695c90 100755 --- a/metrics/scaling/k8s_scale.sh +++ b/metrics/scaling/k8s_scale.sh @@ -38,6 +38,8 @@ TEST_NAME="k8s scaling" API_ADDRESS="http://127.0.0.1" API_PORT="8090" +PROXY_CMD="kubectl proxy --port=${API_PORT}" +clean_up_proxy=false # get the number of nodes in the "Ready" state get_num_nodes() { @@ -113,8 +115,10 @@ init() { port=$(ps -ef | awk '$8 == "kubectl" && $9 == "proxy" {print $10}' | cut -b1-7 --complement) if [ -z $port ]; then echo "starting kubectl proxy" - kubectl proxy --port=${API_PORT} & + clean_up_proxy=true + ${PROXY_CMD} & else + echo "found proxy port: ${port}" API_PORT=$port fi fi @@ -162,9 +166,9 @@ run() { local runtime_command if [ "$use_kata_runtime" != "no" ]; then - runtime_command="s|@RUNTIMECLASS@|${RUNTIME}|g" + runtime_command="s|@RUNTIMECLASS@|${RUNTIME}|g" else - runtime_command="/@RUNTIMECLASS@/d" + runtime_command="/@RUNTIMECLASS@/d" fi local input_template @@ -241,6 +245,12 @@ EOF metrics_json_add_fragment "$json" metrics_json_save + + # if this script launched the proxy, clean it up to prevent hang on exit + if [ "$clean_up_proxy" = "true" ]; then + echo "cleaning up kubectl proxy" + kill $(pgrep -f "${PROXY_CMD}") + fi } show_vars()