Skip to content

Instantly share code, notes, and snippets.

@samuelkarp
Last active April 19, 2016 18:45
Show Gist options
  • Save samuelkarp/515e8ab0ba979623b9acb4b104f78311 to your computer and use it in GitHub Desktop.
Save samuelkarp/515e8ab0ba979623b9acb4b104f78311 to your computer and use it in GitHub Desktop.
#!/bin/bash
sudo docker pull registry:2
cd /proc/$(pidof docker)/task
if [ "$?" -ne 0 ]; then
echo >&2 "/proc/$(pidof docker)/task doesn't exist or isn't a directory."
exit 1
fi
# Run a loop 100 times.
# Each iteration of the loop will start
# ten containers in parallel, then stop them in parallel.
# After the containers have stopped, check that all of
# the docker daemon's threads are in the same namespace.
# This is essentially the same repro as
# https://github.com/docker/libnetwork/issues/1113
# but with many more tries, since the bug is non-deterministic
i=1
while [ "${i}" -le "100" ]; do
seq 10 | xargs -I{} -P10 sudo docker run -d registry:2
if [ "$?" -ne 0 ]; then
echo >&2 "Failed to start all containers"
exit 1
fi
sudo docker ps -q | xargs sudo docker stop
if [ "$?" -ne 0 ]; then
echo >&2 "Failed to stop all container"
exit 1
fi
namespacecount=$(sudo ls -l */ns/net \
| awk '{print $NF}' \
| sort -u \
| wc -l)
[ "${namespacecount}" -eq "1" ]
if [ "$?" -ne 0 ]; then
echo >&2 "FATAL: Daemons threads found using ${namespacecount} different namespaces"
exit 1
fi
let i++
done
echo "All daemon threads used the same namespace"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment