VOL-3164 - add support for release name
Change-Id: I0ee72bdd50f953c3a02aa762e614aff35e850b8b
diff --git a/voltha b/voltha
index ff3897c..e85aaa1 100755
--- a/voltha
+++ b/voltha
@@ -819,32 +819,56 @@
local PORTS="$*"
local TAG=$SVC-$NAME
- (set -x; _TAG="$TAG" bash -c "while true; do kubectl port-forward --address 0.0.0.0 -n $NS service/$SVC $PORTS; done" >>"$LOG" 2>&1 &) >>"$LOG" 2>&1
+ (set -x; _TAG="$TAG" bash -c "while true; do kubectl port-forward --address 0.0.0.0 -n $NS service/$SVC $PORTS; done" >>"$PFLOG" 2>&1 &) >>"$PFLOG" 2>&1
}
kill_port_forward() {
- local TAG P_IDS PARENTS KIDS UNKNOWN PP_ID
- TAG=
- if [ "$1" != "__ALL__" ]; then
- TAG="$1-$NAME"
- fi
- # shellcheck disable=SC2009
- P_IDS="$(ps e -ww -A | grep "_TAG=$TAG" | grep -v grep | awk '{print $1}')"
- if [ -n "$P_IDS" ]; then
- for P_ID in $P_IDS; do
- PP_ID="$(ps -o ppid "$P_ID" | tail -n +2)"
- if [ -n "$PP_ID" ]; then
- if [ "$PP_ID" -eq 1 ]; then
- PARENTS="$PARENTS $P_ID"
+ local TAG P_IDS PARENTS KIDS UNKNOWN PP_ID PF
+
+ while [ $# -gt 0 ]; do
+ PF=$1; shift
+ TAG=
+ if [ "$PF" != "__ALL__" ]; then
+ TAG="$PF-$NAME"
+ fi
+ PARENTS=
+ KIDS=
+ UNKNOWN=
+ # shellcheck disable=SC2009
+ P_IDS="$(ps e -ww -A | grep "_TAG=$TAG" | grep -v grep | awk '{print $1}')"
+ if [ -n "$P_IDS" ]; then
+ for P_ID in $P_IDS; do
+ PP_ID="$(ps -o ppid "$P_ID" | tail -n +2)"
+ if [ -n "$PP_ID" ]; then
+ if [ "$PP_ID" -eq 1 ]; then
+ PARENTS="$PARENTS $P_ID"
+ else
+ KIDS="$KIDS $P_ID"
+ fi
else
- KIDS="$KIDS $P_ID"
+ UNKNOWN="$UNKNOWN $P_ID"
fi
- else
- UNKNOWN="$UNKNOWN $P_ID"
+ done
+ if [ -n "$PARENTS" ]; then
+ # shellcheck disable=SC2086
+ while ps -h $PARENTS >/dev/null 2>&1; do
+ (set -x; eval "kill -9 $PARENTS" >>"$LOG" 2>&1) >>"$LOG" 2>&1
+ done
fi
- done
- (set -x; eval "kill -9 $PARENTS $KIDS $UNKNOWN" >>"$LOG" 2>&1) >>"$LOG" 2>&1
- fi
+ if [ -n "$KIDS" ]; then
+ # shellcheck disable=SC2086
+ while ps -h $KIDS >/dev/null 2>&1; do
+ (set -x; eval "kill -9 $KIDS" >>"$LOG" 2>&1) >>"$LOG" 2>&1
+ done
+ fi
+ if [ -n "$UNKNOWN" ]; then
+ # shellcheck disable=SC2086
+ while ps -h $UNKNOWN >/dev/null 2>&1; do
+ (set -x; eval "kill -9 $UNKNOWN" >>"$LOG" 2>&1) >>"$LOG" 2>&1
+ done
+ fi
+ fi
+ done
}
resolve_chart_version() {
@@ -875,7 +899,7 @@
kill_port_forward onos-onos-classic-hs
fi
sspin "Remove port-forwards: voltha-api-$NAME$CEOL"
- kill_port_forward voltha-api
+ kill_port_forward voltha-api voltha-voltha-api
if is_in "$WITH_ETCD" "yes,external"; then
sspin "Remove port-forwards: etcd-$NAME$CEOL"
kill_port_forward "etcd"
@@ -887,10 +911,10 @@
if [ "$WITH_PPROF" == "yes" ]; then
sspin "Remove port-forwards: *-profiler$CEOL"
- kill_port_forward voltha-rw-core-profiler
- kill_port_forward voltha-of-agent-profiler
+ kill_port_forward voltha-rw-core-profiler voltha-voltha-rw-core-profiler
+ kill_port_forward voltha-of-agent-profiler voltha-voltha-of-agent-profiler
if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
- kill_port_forward adapter-open-olt-profiler
+ kill_port_forward adapter-open-olt-profiler open-olt-adapter-open-olt-profiler
fi
fi
@@ -1048,6 +1072,7 @@
fi
LOG="install-$NAME.log"
+PFLOG="port-forward-$NAME.log"
date > "$LOG"
echo "PORTS=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT" >> "$LOG"
@@ -1388,7 +1413,11 @@
espin "$VERIFIED"
fi
- KUBECONFIG="$(kind get kubeconfig-path --name="voltha-$NAME")"; export KUBECONFIG
+ export KUBECONFIG="./kube-config-$NAME"
+ kind get kubeconfig --name="voltha-$NAME" >"$KUBECONFIG"
+ # For backward compatibility also copy to old location
+ cp "KUBECONFIG" "$HOME/.kube/kind-config-voltha-$NAME"
+
P="coredns-.* \
etcd-voltha-$NAME-control-plane \
kindnet-.* \
@@ -2115,8 +2144,13 @@
if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
STIME="$(date +%s)"
bspin - "Forward VOLTHA API port $FORWARD"
- kill_port_forward voltha-api
- port_forward "$VOLTHA_NS" voltha-api "$VOLTHA_API_PORT:55555"
+ kill_port_forward voltha-api voltha-voltha-api
+ VOLTHA_PREFIX=
+ if kubectl get -n "$VOLTHA_NS" "svc/voltha-voltha-api" >/dev/null 2>&1; then
+ VOLTHA_PREFIX="voltha-"
+ fi
+
+ port_forward "$VOLTHA_NS" "${VOLTHA_PREFIX}voltha-api" "$VOLTHA_API_PORT:55555"
espin - "$VERIFIED"
if is_in "$WITH_ETCD" "yes,external"; then
bspin - "Forward VOLTHA ETCD port $FORWARD"
@@ -2131,13 +2165,17 @@
espin - "$VERIFIED"
fi
if [ "$WITH_PPROF" == "yes" ]; then
+ VOLTHA_OPENOLT_PREFIX=
+ if kubectl get -n "$ADAPTER_NS" "svc/open-olt-adapter-open-olt-profiler" >/dev/null 2>&1; then
+ VOLTHA_OPENOLT_PREFIX="open-olt-"
+ fi
bspin - "Forward PProf ports port $FORWARD"
- kill_port_forward voltha-rw-core-profiler
- kill_port_forward adapter-open-olt-profiler
- kill_port_forward voltha-of-agent-profiler
- port_forward "$VOLTHA_NS" voltha-rw-core-profiler "$VOLTHA_PPROF_PORT:6060"
- port_forward "$VOLTHA_NS" adapter-open-olt-profiler "$OPENOLT_PPROF_PORT:6060"
- port_forward "$VOLTHA_NS" voltha-of-agent-profiler "$OFAGENT_PPROF_PORT:6060"
+ kill_port_forward voltha-rw-core-profiler voltha-voltha-rw-core-profiler
+ kill_port_forward adapter-open-olt-profiler open-olt-adapter-open-olt-profiler
+ kill_port_forward voltha-of-agent-profiler voltha-voltha-of-agent-profiler
+ port_forward "$VOLTHA_NS" "${VOLTHA_PREFIX}voltha-rw-core-profiler" "$VOLTHA_PPROF_PORT:6060"
+ port_forward "$ADAPTER_NS" "${VOLTHA_OPENOLT_PREFIX}adapter-open-olt-profiler" "$OPENOLT_PPROF_PORT:6060"
+ port_forward "$VOLTHA_NS" "${VOLTHA_PREFIX}voltha-of-agent-profiler" "$OFAGENT_PPROF_PORT:6060"
espin - "$VERIFIED"
fi
if [ "$WITH_TIMINGS" == "yes" ]; then