Last active
January 5, 2021 11:43
-
-
Save JohnMorales/4a4277510190d187bac5 to your computer and use it in GitHub Desktop.
Closes leaked deleted and eventfd left by docker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin | |
docker_pid=$(cat /var/run/docker.pid) | |
gdb -p $docker_pid <<< "$( ls /proc/$docker_pid/fd -l --time-style=+'%s' | grep -E 'deleted' | awk '{ printf("p close(%s)\n", $7)}')" >/dev/null | |
#closing evenfds that do not have a corresponding memory.oom_control | |
eventfds="$(for eventfd in $(ls /proc/$docker_pid/fd -l --time-style=+'%s' | grep -E 'eventfd'| awk '{print $7}'); do | |
memory_pid=$((eventfd - 1)) | |
if [ -f /proc/$docker_pid/fd/$memory_pid ] && ! ( ls -l /proc/$docker_pid/fd/$memory_pid | grep 'memory.oom_control' >/dev/null ) ; then | |
echo "p close($eventfd)" | |
fi | |
done)" | |
gdb -p $docker_pid <<< "$eventfds" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment