Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
af1e1c3c
Commit
af1e1c3c
authored
Apr 13, 2016
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #23992 from mml/docker-checker
Automatic merge from submit-queue Rewrite docker-checker.sh to make it less kill-happy.
parents
97acf8ca
e6af5ee2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
28 deletions
+60
-28
docker-checker.sh
cluster/saltbase/salt/supervisor/docker-checker.sh
+60
-28
No files found.
cluster/saltbase/salt/supervisor/docker-checker.sh
View file @
af1e1c3c
...
@@ -18,38 +18,70 @@
...
@@ -18,38 +18,70 @@
# it detects a failure. It then exits, and supervisord restarts it
# it detects a failure. It then exits, and supervisord restarts it
# which in turn restarts docker.
# which in turn restarts docker.
/etc/init.d/docker stop
main
()
{
# Make sure docker gracefully terminated before start again
if
!
healthy 60
;
then
starttime
=
`
date
+%s
`
stop_docker
while
pidof docker
>
/dev/null
;
do
start_docker
currenttime
=
`
date
+%s
`
echo
"waiting 30s for startup"
((
elapsedtime
=
currenttime - starttime
))
sleep
30
# after 60 seconds, forcefully terminate docker process
healthy 60
if
test
$elapsedtime
-gt
60
;
then
fi
echo
"attempting to kill docker process with sigkill signal"
kill
-9
`
pidof docker
`
||
sleep
10
while
healthy
;
do
sleep
10
done
echo
"Docker failed!"
exit
2
}
# Performs health check on docker. If a parameter is passed, it is treated as
# the number of seconds to keep trying for a healthy result. If none is passed
# we make only one attempt.
healthy
()
{
max_retry_sec
=
"
$1
"
shift
starttime
=
$(
date
+%s
)
while
!
timeout
60 docker ps
>
/dev/null
;
do
if
[[
-z
"
$max_retry_sec
"
||
$((
$(
date
+%s
)
-
starttime
))
-gt
"
$max_retry_sec
"
]]
;
then
echo
"docker ps did not succeed"
return
2
else
else
echo
"waiting
clean shutdown
"
echo
"waiting
5s before retry
"
sleep
10
sleep
5
fi
fi
done
done
echo
"docker is healthy"
echo
"docker is not running. starting docker"
return
0
}
# cleanup docker network checkpoint to avoid running into known issue
stop_docker
()
{
# of docker (https://github.com/docker/docker/issues/18283)
/etc/init.d/docker stop
rm
-rf
/var/lib/docker/network
# Make sure docker gracefully terminated before start again
starttime
=
`
date
+%s
`
while
pidof docker
>
/dev/null
;
do
currenttime
=
`
date
+%s
`
((
elapsedtime
=
currenttime - starttime
))
# after 60 seconds, forcefully terminate docker process
if
test
$elapsedtime
-gt
60
;
then
echo
"attempting to kill docker process with sigkill signal"
kill
-9
`
pidof docker
`
||
sleep
10
else
echo
"waiting clean shutdown"
sleep
10
fi
done
}
/etc/init.d/docker start
start_docker
()
{
echo
"docker is not running. starting docker"
echo
"waiting 30s for startup"
# cleanup docker network checkpoint to avoid running into known issue
sleep
30
# of docker (https://github.com/docker/docker/issues/18283)
rm
-rf
/var/lib/docker/network
while
true
;
do
/etc/init.d/docker start
if
!
timeout
60 docker ps
>
/dev/null
;
then
}
echo
"Docker failed!"
exit
2
fi
sleep
10
done
main
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment