Fixing and issue where if the pids in the orphan list no longer exist then all systemd child processes would be killed. (#5636)
This commit is contained in:
parent
36c1f32ef9
commit
b51b52ac0e
1 changed files with 2 additions and 7 deletions
|
@ -9,21 +9,16 @@ list_descendants ()
|
||||||
[[ -n "$children" ]] && echo "$children"
|
[[ -n "$children" ]] && echo "$children"
|
||||||
}
|
}
|
||||||
|
|
||||||
shim_search="^docker-containerd-shim"
|
shim_search="^docker-containerd-shim|^containerd-shim"
|
||||||
count_shim_processes=$(pgrep -f $shim_search | wc -l)
|
count_shim_processes=$(pgrep -f $shim_search | wc -l)
|
||||||
|
|
||||||
if [ ${count_shim_processes} -eq 0 ]; then
|
|
||||||
shim_search="^containerd-shim"
|
|
||||||
count_shim_processes=$(pgrep -f $shim_search | wc -l)
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ${count_shim_processes} -gt 0 ]; then
|
if [ ${count_shim_processes} -gt 0 ]; then
|
||||||
# Find all container pids from shims
|
# Find all container pids from shims
|
||||||
orphans=$(pgrep -P $(pgrep -d ',' -f $shim_search) |\
|
orphans=$(pgrep -P $(pgrep -d ',' -f $shim_search) |\
|
||||||
# Filter out valid docker pids, leaving the orphans
|
# Filter out valid docker pids, leaving the orphans
|
||||||
egrep -v $(docker ps -q | xargs docker inspect --format '{{.State.Pid}}' | awk '{printf "%s%s",sep,$1; sep="|"}'))
|
egrep -v $(docker ps -q | xargs docker inspect --format '{{.State.Pid}}' | awk '{printf "%s%s",sep,$1; sep="|"}'))
|
||||||
|
|
||||||
if [[ -n "$orphans" ]]
|
if [[ -n "$orphans" && -n "$(ps -o ppid= $orphans)" ]]
|
||||||
then
|
then
|
||||||
# Get shim pids of orphans
|
# Get shim pids of orphans
|
||||||
orphan_shim_pids=$(ps -o pid= $(ps -o ppid= $orphans))
|
orphan_shim_pids=$(ps -o pid= $(ps -o ppid= $orphans))
|
||||||
|
|
Loading…
Reference in a new issue