Added some minor changes to the docker orphan clean up process. (#3657)
* Added changes to clean up orphan containers and reload docker & kubelet directories. * Added new files for cleaning up orphans and docker & kubelet directories * Added new lines at the end of these files * removed the trailing whitespaces from main.yml and clean-up.yml * Updated as per the review comments * Updated as per the review comments * Removed service_facts and package_facts because they are not supported in ansible 2.4.0 * Corrected yaml syntax errors * Removed the use of json_query filter and utilized selectattr * Removed trailing spaces * Changed the default value of docker_clean_up to false * Added Changes to only include cleanup-docker-orphans.sh * Reverted back changes done inside handler. * Removed trailing spaces and made default value of docker_orphan_clean_up as true * Reverted the default value of docker_orphan_clean_up as false * Made the docker clean up as drop in * Made the docker clean up as drop in * Reverted the value of boolean docker_orphan_clean_up to false * Converted ExecStop to ExecSTartPost. Removed the live restore check from the orphan script
This commit is contained in:
parent
14c2df0418
commit
113dd2146a
2 changed files with 6 additions and 6 deletions
|
@ -10,9 +10,9 @@ list_descendants ()
|
||||||
}
|
}
|
||||||
|
|
||||||
count_shim_processes=$(pgrep -f ^docker-containerd-shim | wc -l)
|
count_shim_processes=$(pgrep -f ^docker-containerd-shim | wc -l)
|
||||||
live_restore=$(docker info --format {{.LiveRestoreEnabled}} 2>/dev/null)
|
|
||||||
|
|
||||||
if [ ${count_shim_processes} -gt 0 ] && [ -n "${live_restore}" -a "${live_restore}" == "true" ]; 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 ^docker-containerd-shim) |\
|
orphans=$(pgrep -P $(pgrep -d ',' -f ^docker-containerd-shim) |\
|
||||||
# Filter out valid docker pids, leaving the orphans
|
# Filter out valid docker pids, leaving the orphans
|
||||||
|
@ -28,11 +28,11 @@ if [ ${count_shim_processes} -gt 0 ] && [ -n "${live_restore}" -a "${live_restor
|
||||||
|
|
||||||
# Recursively kill all child PIDs of orphan shims
|
# Recursively kill all child PIDs of orphan shims
|
||||||
echo -e "Killing orphan container PIDs and descendants: \n$(ps -O ppid= $orphan_container_pids)"
|
echo -e "Killing orphan container PIDs and descendants: \n$(ps -O ppid= $orphan_container_pids)"
|
||||||
#kill -9 $orphan_container_pids || true
|
kill -9 $orphan_container_pids || true
|
||||||
|
|
||||||
else
|
else
|
||||||
echo "No orphaned containers found"
|
echo "No orphaned containers found"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Either live-restore is turned off or the node doesn't have any shim processes."
|
echo "The node doesn't have any shim processes."
|
||||||
fi
|
fi
|
|
@ -1,2 +1,2 @@
|
||||||
[Service]
|
[Service]
|
||||||
ExecStop=-{{ bin_dir }}/cleanup-docker-orphans.sh
|
ExecStartPost=-{{ bin_dir }}/cleanup-docker-orphans.sh
|
Loading…
Reference in a new issue