ES OOM alignment 27/29527/2
authorTal Gitelman <tg851x@intl.att.com>
Mon, 29 Jan 2018 15:24:56 +0000 (17:24 +0200)
committerMichael Lando <ml636r@att.com>
Mon, 29 Jan 2018 17:22:07 +0000 (17:22 +0000)
Change-Id: I798502516a4b9200243ed072985faa9f528f2073
Issue-ID: SDC-912
Signed-off-by: Tal Gitelman <tg851x@intl.att.com>
sdc-os-chef/scripts/docker_run.sh
sdc-os-chef/sdc-elasticsearch/startup.sh
sdc-os-chef/sdc-init-elasticsearch/startup.sh

index 2a8591c..7e5498e 100755 (executable)
@@ -64,7 +64,7 @@ function healthCheck {
 
        echo ""
        echo ""
-       healthCheck_http_code=$(curl -o out.html -w '%{http_code}' -H "Accept: application/json" -H "Content-Type: application/json" -H "USER_ID: jh0003" http://localhost:8080/sdc2/rest/v1/user/demo;)
+       healthCheck_http_code=$(curl -o /dev/null -w '%{http_code}' -H "Accept: application/json" -H "Content-Type: application/json" -H "USER_ID: jh0003" http://localhost:8080/sdc2/rest/v1/user/demo;)
        if [[ ${healthCheck_http_code} != 200 ]]
        then
                echo "Error [${healthCheck_http_code}] while user existance check"
@@ -74,6 +74,32 @@ function healthCheck {
        return ${healthCheck_http_code}
 }
 
+function elasticHealthCheck {
+       echo "Elastic Health-Check:"
+       
+       COUNTER=0
+    while [  $COUNTER -lt 20 ]; do
+       echo "Waiting ES docker to start"
+               health_Check_http_code=$(curl -o /dev/null -w '%{http_code}' http://localhost:9200/_cluster/health?wait_for_status=yellow&timeout=120s)
+               if [[ "$health_Check_http_code" -eq 200 ]]
+               then
+                       break
+               fi
+               let COUNTER=COUNTER+1 
+               sleep 4
+       done
+       
+       healthCheck_http_code=$(curl -o /dev/null -w '%{http_code}' http://localhost:9200/_cluster/health?wait_for_status=yellow&timeout=120s)
+       if [[ "$health_Check_http_code" != 200 ]]
+       then
+               echo "Error [${healthCheck_http_code}] ES NOT started correctly"
+               exit ${healthCheck_http_code}
+       fi
+       echo "ES started correctly"
+       curl localhost:9200/_cluster/health?pretty=true
+       return ${healthCheck_http_code}
+}
+
 RELEASE=latest
 LOCAL=false
 RUNTESTS=false
@@ -140,7 +166,9 @@ if [ ${LOCAL} = false ]; then
        echo "pulling code"
        docker pull ${PREFIX}/sdc-elasticsearch:${RELEASE}
 fi
-docker run --detach --name sdc-es --env ENVNAME="${DEP_ENV}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --memory 750m --env ES_JAVA_OPTS="-Xms512m -Xmx512m" --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro --env ES_HEAP_SIZE=1024M --volume ${WORKSPACE}/data/ES:/usr/share/elasticsearch/data --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --publish 9200:9200 --publish 9300:9300 ${PREFIX}/sdc-elasticsearch:${RELEASE}
+docker run -dit --name sdc-es --env ENVNAME="${DEP_ENV}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --memory 750m --env ES_JAVA_OPTS="-Xms512m -Xmx512m" --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro --env ES_HEAP_SIZE=1024M --volume ${WORKSPACE}/data/ES:/usr/share/elasticsearch/data --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --publish 9200:9200 --publish 9300:9300 ${PREFIX}/sdc-elasticsearch:${RELEASE} /bin/sh
+
+elasticHealthCheck
 
 # Init-Elastic-Search
 echo "docker run sdc-init-elasticsearch..."
@@ -148,7 +176,13 @@ if [ ${LOCAL} = false ]; then
        echo "pulling code"
        docker pull ${PREFIX}/sdc-init-elasticsearch:${RELEASE}
 fi
-docker run --detach --name sdc-init-es --env ENVNAME="${DEP_ENV}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --memory 750m --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments ${PREFIX}/sdc-init-elasticsearch:${RELEASE}
+docker run --name sdc-init-es --env ENVNAME="${DEP_ENV}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --memory 750m --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments ${PREFIX}/sdc-init-elasticsearch:${RELEASE} 
+
+# Checking Elastic-Search-Init chef status
+if [ ! $? -eq 0 ]; then
+    echo "Elastic-Search Initialization failed"
+    exit $?
+fi
 
 # Cassandra
 echo "docker run sdc-cassandra..."
index 6c9b0c0..1871d68 100644 (file)
@@ -3,7 +3,8 @@
 cd /root/chef-solo/
 chef-solo -c solo.rb -E ${ENVNAME}
 
-/docker-entrypoint.sh elasticsearch &
+chef_status=$?
 
-while true; do sleep 2; done
+/docker-entrypoint.sh elasticsearch &
 
+exec "$@";
\ No newline at end of file
index ac26052..9a8cbc3 100644 (file)
@@ -2,3 +2,5 @@
 
 cd /root/chef-solo/
 chef-solo -c solo.rb -E ${ENVNAME}
+
+exit $?
\ No newline at end of file