add timeout for loops and update to new image names
diff --git a/README.md b/README.md
index 91dadaf..44a2df3 100644
--- a/README.md
+++ b/README.md
@@ -119,6 +119,7 @@
| `ENABLE_ONOS_EXTRANEOUS_RULES` | no | Set ONOS to allows flow rules not set via ONOS |
| `UPDATE_HELM_REPOS` | yes | Update the Helm repository with the latest charts before installing |
| `WAIT_ON_DOWN` | yes | When tearing down the VOLTHA, don't exit script until all containers are stoped |
+| `WAIT_TIMEOUT` | 30m | Time to wait before timing out on lengthy operations |
| `KIND_VERSION` | v0.5.1 | Version of KinD to install if using a KinD cluster |
| `VOLTCTL_VERSION` | latest | Version of `voltctl` to install or up/downgrade to and use |
| `ONOS_API_PORT` | dynamic | (advanced) Override dynamic port selection for port forward for ONOS API |
diff --git a/full-values.yaml b/full-values.yaml
index 0688676..e9402c1 100644
--- a/full-values.yaml
+++ b/full-values.yaml
@@ -36,9 +36,6 @@
# information below (search for START_OFAGENT_GO).
use_ofagent_go: true
-replicas:
- cli: ~
-
images:
onos:
repository: voltha/voltha-onos
@@ -73,12 +70,12 @@
# tag: master
# START_OFAGENT_GO - Comment the following block to use the Python implementation
# of the ofagent
- ofagent:
- repository: voltha/ofagent-go
- tag: master
+# ofagent:
+# repository: voltha/voltha-ofagent-go
+# tag: master
# END_OFAGENT_GO
# ofagent:
-# repository: voltha/voltha-ofagent
+# repository: voltha/voltha-ofagent-py
# tag: 2.1.1
# rw_core:
# repository: voltha/voltha-rw-core
diff --git a/minimal-values.yaml b/minimal-values.yaml
index 6844b58..fdf4614 100644
--- a/minimal-values.yaml
+++ b/minimal-values.yaml
@@ -36,9 +36,6 @@
# information below (search for START_OFAGENT_GO).
use_ofagent_go: true
-replicas:
- cli: ~
-
images:
onos:
repository: voltha/voltha-onos
@@ -73,12 +70,12 @@
# tag: master
# START_OFAGENT_GO - Comment the following block to use the Python implementation
# of the ofagent
- ofagent:
- repository: voltha/ofagent-go
- tag: master
+# ofagent:
+# repository: voltha/voltha-ofagent-go
+# tag: master
# END_OFAGENT_GO
# ofagent:
-# repository: voltha/voltha-ofagent
+# repository: voltha/voltha-ofagent-py
# tag: 2.1.1
# rw_core:
# repository: voltha/voltha-rw-core
diff --git a/voltha b/voltha
index 983882e..af9dc0e 100755
--- a/voltha
+++ b/voltha
@@ -94,6 +94,8 @@
INSTALL_HELM=${INSTALL_HELM:-yes}
UPDATE_HELM_REPOS=${UPDATE_HELM_REPOS:-yes}
WAIT_ON_DOWN=${WAIT_ON_DOWN:-yes}
+WAIT_TIMEOUT=${WAIT_TIMEOUT:-30m}
+VOLTHA_DOWN_ON_TIMEOUT=${VOLTHA_DOWN_ON_TIMEOUT:-no}
VOLTHA_LOG_LEVEL=${VOLTHA_LOG_LEVEL:-WARN}
VOLTHA_CHART=${VOLTHA_CHART:-onf/voltha}
VOLTHA_CHART_VERSION=${VOLTHA_CHART_VERSION:-latest}
@@ -137,6 +139,34 @@
exit 1
fi
+function parseDuration() {
+ local DUR=$1
+ local RESULT=0
+ local TERMS=$(echo $DUR | sed -e 's/\([sSmMhHdD]\)/\1 /g' -e 's/,$//g')
+ for TERM in $TERMS; do
+ local VALUE=$(echo $TERM | sed -e 's/\([0-9]\+\)[sSmMhHdD]/\1/')
+ local UNIT=$(echo $TERM | sed -e 's/[0-9]\+\([sSmMhHdD]\)/\1/')
+ case $UNIT in
+ s|S)
+ RESULT=$(($RESULT + $VALUE)) ;;
+ m|M)
+ RESULT=$(($RESULT + ($VALUE * 60))) ;;
+ h|H)
+ RESULT=$(($RESULT + ($VALUE * 3600))) ;;
+ d|D)
+ RESULT=$(($RESULT + ($VALUE * 86400))) ;;
+ *) ;;
+ esac
+ done
+ echo $RESULT
+}
+
+function doTimeout() {
+ local MSG=$1
+ 2>&1 echo -e "\n${RED}${BOLD}${ERROR}TIMEOUT:${NORMAL}${RED} Operation timed out after '$WAIT_TIMEOUT': $MSG"
+ exit 125
+}
+
function get_service_ep() {
local NS=$1
local NAME=$2
@@ -183,12 +213,14 @@
UPDATE_HELM_REPOS \
WAIT_ON_DOWN \
ONLY_ONE \
+ VOLTHA_DOWN_ON_TIMEOUT \
"
ALL_OPTIONS="\
NAME \
TYPE \
$ALL_YES_NO \
+ WAIT_TIMEOUT \
VOLTHA_LOG_LEVEL \
VOLTHA_CHART \
VOLTHA_CHART_VERSION \
@@ -241,6 +273,8 @@
exit 1
fi
+TIMEOUT_SECONDS=$(parseDuration $WAIT_TIMEOUT)
+
mkdir -p .voltha
touch .voltha/ports
HAVE=$(grep $NAME .voltha/ports)
@@ -453,9 +487,14 @@
local CMD_ECHO=$(mktemp -u)
local CMD_OUTPUT=$(mktemp -u)
local SC_OUTPUT=$(mktemp -u)
+ local WAIT_START=$(date +%s)
bspin - "$MSG $GEAR"
while true; do
+ if [ $(($(date +%s) - $WAIT_START)) -gt $TIMEOUT_SECONDS ]; then
+ espin - "$THEX"
+ doTimeout "waiting for ONOS config push on $RESOURCE"
+ fi
if [ $TYPE == "file" ]; then
(set -x; curl --fail -sSL --user karaf:karaf -w "%{http_code}" -o $CMD_OUTPUT -X POST -H Content-Type:application/json http://$_ONOS_API_EP/onos/v1/$RESOURCE --data @$DATA >$SC_OUTPUT 2>/dev/null) >>$CMD_ECHO 2>&1
RESULT=$?
@@ -483,25 +522,36 @@
}
check_onos_app_active() {
- local APP_ID=$1
+ local APP_ID=$1
+ local WAIT_START=$(date +%s)
- bspin - "Checking that $APP_ID is active $CLOCK"
- while true; do
- (set -x; curl --fail -sSL --user karaf:karaf -X GET http://$_ONOS_API_EP/onos/v1/applications/$APP_ID | grep ACTIVE >>$LOG 2>&1) >>$LOG 2>&1
- if [ $? -eq 0 ]; then
- break
- fi
- sleep 1
- sspin -
- done
- sleep 5 # OSGI components take a little longer that the app to activate
- espin - $VERIFIED
+ bspin - "Checking that $APP_ID is active $CLOCK"
+ while true; do
+ if [ $(($(date +%s) - $WAIT_START)) -gt $TIMEOUT_SECONDS ]; then
+ espin - "$THEX"
+ doTimeout "waiting for ONOS application activation '$APP_ID'"
+ fi
+ (set -x; curl --fail -sSL --user karaf:karaf -X GET http://$_ONOS_API_EP/onos/v1/applications/$APP_ID | grep ACTIVE >>$LOG 2>&1) >>$LOG 2>&1
+ if [ $? -eq 0 ]; then
+ break
+ fi
+ sleep 1
+ sspin -
+ done
+ sleep 5 # OSGI components take a little longer that the app to activate
+ espin - $VERIFIED
}
override_onos_app() {
local APP=$1
local NAME=$(basename $APP | sed -e 's/^[0-9][0-9]*-//g' -e 's/-.*$//g')
+ local WAIT_START=$(date +%s)
+
while true; do
+ if [ $(($(date +%s) - $WAIT_START)) -gt $TIMEOUT_SECONDS ]; then
+ espin - "$THEX"
+ doTimeout "waiting to overwrite ONOS application '$APP'"
+ fi
sspin -
# Attempt to delete old version (if it exists)
(set -x; curl --fail -sSL --user karaf:karaf -X DELETE http://$_ONOS_API_EP/onos/v1/applications/$NAME >>$LOG 2>&1) >>$LOG 2>&1
@@ -520,9 +570,14 @@
activate_onos_app() {
local MSG="$1"
local APP=$2
+ local WAIT_START=$(date +%s)
bspin - "$MSG $GO"
while true; do
+ if [ $(($(date +%s) - $WAIT_START)) -gt $TIMEOUT_SECONDS ]; then
+ espin - "$THEX"
+ doTimeout "waiting to activate ONOS application '$APP'"
+ fi
sspin -
(set -x; curl --fail -sSL --user karaf:karaf -X POST http://$_ONOS_API_EP/onos/v1/applications/$APP/active >>$LOG 2>&1) >>$LOG 2>&1
if [ $? -eq 0 ]; then
@@ -585,10 +640,15 @@
ALL=$(count_pods "all-namespaces" "*" ".*")
fi
COUNT=$(expr 300 / 15)
+ local WAIT_START=$(date +%s)
bspin $INDENT $MESSAGE
sspin $INDENT
if [ $HAVE -ne $EXPECT -o $ALL -ne $HAVE ]; then
while [ $HAVE -ne $EXPECT -o $ALL -ne $HAVE ]; do
+ if [ $(($(date +%s) - $WAIT_START)) -gt $TIMEOUT_SECONDS ]; then
+ espin $INDENT "$THEX"
+ doTimeout "waiting for PODs to start"
+ fi
sspin $INDENT
COUNT=$(expr $COUNT - 1)
if [ $COUNT -eq 0 ]; then
@@ -807,11 +867,16 @@
CHART_ARGS="-f ${INAME}-values.yaml"
fi
+ local WAIT_START=$(date +%s)
COUNT=$(expr 300 / 15)
bspin $INDENT $MESSAGE
(set -x; helm install -f $NAME-values.yaml $CHART_ARGS $INTERNAL_EXTRA_HELM_INSTALL_ARGS $EXTRA_HELM_INSTALL_ARGS --set defaults.log_level=$VOLTHA_LOG_LEVEL --namespace $NAMESPACE --name $INAME $CHART_VERSION $EXTRA_HELM_FLAGS $CHART >>$LOG 2>&1) >>$LOG 2>&1
SUCCESS=$?
while [ $SUCCESS -ne 0 ]; do
+ if [ $(($(date +%s) - $WAIT_START)) -gt $TIMEOUT_SECONDS ]; then
+ espin "$THEX"
+ doTimeout "waiting for helm install $CHART"
+ fi
sspin $INDENT
COUNT=$(expr $COUNT - 1)
if [ $COUNT -eq 0 ]; then