Execute docker health commands with docker group 02/9702/1
authorendika <endika.aldecoa@ehu.eus>
Fri, 11 Sep 2020 13:19:52 +0000 (15:19 +0200)
committerendika <endika.aldecoa@ehu.eus>
Fri, 11 Sep 2020 13:39:29 +0000 (15:39 +0200)
Fixes bug #1205

Change-Id: Iccf15a31c4925421820e25d7c0821e322955267a
Signed-off-by: endika <endika.aldecoa@ehu.eus>
installers/osm_health.sh

index 0f7922a..e7c8065 100755 (executable)
@@ -54,7 +54,7 @@ while [ $time -le "$WAIT_TIME" ]; do
             exit 0
         fi
     else
-        if [ "$(docker ps | grep " ${STACK_NAME}_" | grep -i healthy | wc -l)" -ge "$NUM_SERVICES_WITH_HEALTH" ]; then
+        if [ "$(sg docker -c "docker ps" | grep " ${STACK_NAME}_" | grep -i healthy | wc -l)" -ge "$NUM_SERVICES_WITH_HEALTH" ]; then
             # all dockers are healthy now.
             # final sleep is needed until more health checks are added to validate system is ready to handle requests
             sleep $WAIT_FINAL
@@ -79,12 +79,12 @@ if [ -n "$KUBERNETES" ]; then
     done
 else
     echo "Not all Docker services are healthy"
-    docker ps | grep " ${STACK_NAME}_"
+    sg docker -c "docker ps" | grep " ${STACK_NAME}_"
     for S_WITH_HEALTH in $SERVICES_WITH_HEALTH ; do
-        docker ps | grep " ${STACK_NAME}_" | grep -i healthy | grep -q "_${S_WITH_HEALTH}."  && continue
+        sg docker -c "docker ps" | grep " ${STACK_NAME}_" | grep -i healthy | grep -q "_${S_WITH_HEALTH}."  && continue
         echo
         echo BEGIN LOGS of container ${S_WITH_HEALTH} not healthy
-        docker service logs ${STACK_NAME}_${S_WITH_HEALTH} 2>&1 | tail -n 100
+        sg docker -c "docker service logs ${STACK_NAME}_${S_WITH_HEALTH} 2>&1" | tail -n 100
         echo END LOGS of container ${S_WITH_HEALTH} not healthy
         echo
     done