diff --git a/roles/container-engine/docker/files/cleanup-docker-orphans.sh b/roles/container-engine/docker/files/cleanup-docker-orphans.sh index 5db82f88b..28f7205ab 100644 --- a/roles/container-engine/docker/files/cleanup-docker-orphans.sh +++ b/roles/container-engine/docker/files/cleanup-docker-orphans.sh @@ -10,9 +10,9 @@ list_descendants () } 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 orphans=$(pgrep -P $(pgrep -d ',' -f ^docker-containerd-shim) |\ # 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 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 echo "No orphaned containers found" fi else - echo "Either live-restore is turned off or the node doesn't have any shim processes." -fi \ No newline at end of file + echo "The node doesn't have any shim processes." +fi diff --git a/roles/container-engine/docker/templates/docker-orphan-cleanup.conf.j2 b/roles/container-engine/docker/templates/docker-orphan-cleanup.conf.j2 index 70754ac57..787a941ed 100644 --- a/roles/container-engine/docker/templates/docker-orphan-cleanup.conf.j2 +++ b/roles/container-engine/docker/templates/docker-orphan-cleanup.conf.j2 @@ -1,2 +1,2 @@ [Service] -ExecStop=-{{ bin_dir }}/cleanup-docker-orphans.sh \ No newline at end of file +ExecStartPost=-{{ bin_dir }}/cleanup-docker-orphans.sh \ No newline at end of file