Skip to content

Commit

Permalink
Merge pull request #6448 from tsuna/healthcheck
Browse files Browse the repository at this point in the history
Fix docker-healthcheck to work around Docker bug.
  • Loading branch information
k8s-ci-robot authored Mar 16, 2019
2 parents 72bca14 + b67cf8f commit d2db91b
Showing 1 changed file with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,19 @@
# This script is intended to be run periodically, to check the health
# of docker. If it detects a failure, it will restart docker using systemctl.

if timeout 60 docker ps > /dev/null; then
healthcheck() {
if output=`timeout 60 docker network ls`; then
echo "$output" | fgrep -qw host || {
echo "docker 'host' network missing"
return 1
}
else
echo "docker returned $?"
return 1
fi
}

if healthcheck; then
echo "docker healthy"
exit 0
fi
Expand All @@ -26,7 +38,7 @@ echo "docker failed"
echo "Giving docker 30 seconds grace before restarting"
sleep 30

if timeout 60 docker ps > /dev/null; then
if healthcheck; then
echo "docker recovered"
exit 0
fi
Expand All @@ -43,7 +55,7 @@ systemctl start docker
echo "Waiting 120 seconds to give docker time to start"
sleep 60

if timeout 60 docker ps > /dev/null; then
if healthcheck; then
echo "docker recovered"
exit 0
fi
Expand Down

0 comments on commit d2db91b

Please sign in to comment.