summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorSakala Venkata Krishna Rohit <rohitsakala@gmail.com>2017-09-04 16:59:05 +0530
committerSakala Venkata Krishna Rohit <rohitsakala@gmail.com>2017-09-04 17:19:09 +0530
commit2db8a17f896451b70b66882b76b815bc5db8f668 (patch)
treea19bbd1e945d7bc7cd563ffb3d130cb22564f246 /utils
parentbbc57916c38601769aff5650f716c9d373795c22 (diff)
Refactored docker watchdog code
Removed start_containers fix as it was redundant. Checking jenkins job status for each module separately as deployment of one module doesn't depend on other module. Change-Id: I8ce34b9b7458ac56c9b866b5add539ad304095ed Signed-off-by: Sakala Venkata Krishna Rohit <rohitsakala@gmail.com>
Diffstat (limited to 'utils')
-rw-r--r--utils/test/testapi/tools/watchdog/docker_watch.sh63
1 files changed, 25 insertions, 38 deletions
diff --git a/utils/test/testapi/tools/watchdog/docker_watch.sh b/utils/test/testapi/tools/watchdog/docker_watch.sh
index d67e4b380..786fc10b9 100644
--- a/utils/test/testapi/tools/watchdog/docker_watch.sh
+++ b/utils/test/testapi/tools/watchdog/docker_watch.sh
@@ -21,33 +21,19 @@ modules=(testapi reporting)
declare -A ports=( ["testapi"]="8082" ["reporting"]="8084")
## Urls to check if the modules are deployed or not ?
-#declare -A urls=( ["testapi"]="http://testresults.opnfv.org/test/" \
-# ["reporting"]="http://testresults.opnfv.org/reporting2/reporting/index.html")
-
-declare -A urls=( ["testapi"]="http://localhost:8082/" \
+declare -A urls=( ["testapi"]="http://testresults.opnfv.org/test/" \
["reporting"]="http://testresults.opnfv.org/reporting2/reporting/index.html")
-
### Functions related to checking.
function is_deploying() {
- echo -e "Checking job statuses"
- for module in "${modules[@]}"
- do
- if get_status $module; then
- exit 0
- fi
- done
-}
-
-function get_status() {
xml=$(curl -m10 "https://build.opnfv.org/ci/job/${1}-automate-master/lastBuild/api/xml?depth=1")
building=$(grep -oPm1 "(?<=<building>)[^<]+" <<< "$xml")
if [[ $building == "false" ]]
then
- return 1
- else
return 0
+ else
+ return 1
fi
}
@@ -78,6 +64,9 @@ function check_modules() {
failed_modules=()
for module in "${modules[@]}"
do
+ if is_deploying $module; then
+ continue
+ fi
if ! check_connectivity $module "${urls[$module]}"; then
echo -e "$module failed"
failed_modules+=($module)
@@ -110,27 +99,30 @@ function docker_proxy_fix() {
echo $pid
if [ ! -z "$pid" ]; then
kill $pid
- start_containers_fix $module
+ start_container_fix $module
fi
done
}
function start_containers_fix() {
- echo "Runnning start_containers_fix"
start_modules=("${@}")
for module in "${start_modules[@]}"
do
- echo -e "Starting a container $module"
+ start_container_fix $module
+ done
+}
+
+function start_container_fix() {
+ echo -e "Starting a container $module"
+ sudo docker stop $module
+ sudo docker start $module
+ sleep 5
+ if ! check_connectivity $module "${urls[$module]}"; then
+ echo -e "Starting an old container $module_old"
sudo docker stop $module
- sudo docker start $module
+ sudo docker start $module"_old"
sleep 5
- if ! check_connectivity $module "${urls[$module]}"; then
- echo -e "Starting an old container $module_old"
- sudo docker stop $module
- sudo docker start $module"_old"
- sleep 5
- fi
- done
+ fi
}
### Main Flow
@@ -141,11 +133,6 @@ echo -e
echo -e `date "+%Y-%m-%d %H:%M:%S.%N"`
echo -e
-if ! is_deploying; then
- echo -e "Jenkins Jobs running"
- exit
-fi
-
## If the problem is related to docker daemon
if get_docker_status; then
@@ -156,16 +143,16 @@ if get_docker_status; then
exit
fi
-## If the problem is related to docker containers
+## If the problem is related to docker proxy
if ! check_modules; then
- start_containers_fix "${failed_modules[@]}"
+ docker_proxy_fix "${failed_modules[@]}"
fi
-## If the problem is related to docker proxy
+## If any other problem : restart docker
if ! check_modules; then
- docker_proxy_fix "${failed_modules[@]}"
+ restart_docker_fix
fi
## If nothing works out
@@ -175,4 +162,4 @@ if ! check_modules; then
fi
sudo docker ps
-sudo docker images \ No newline at end of file
+sudo docker images